Though this works fine for all the conditions, please check properly before using in production. Return (cardExpiry > DateTime.Now & cardExpiry < (6))
If a website is fake or illegal, use this credit card generator to save yourself from financial fraud. It is a flexible and legal online CC Generator for generating credit card numbers. It is a complete legal tool and binds by all laws laid down by the government.
check expiry greater than today & within next 6 years > Credit Card Generator's primary role is data verification and software testing. Var cardExpiry = new DateTime(year, month, lastDateOfExpiryMonth, 23, 59, 59) Var lastDateOfExpiryMonth = DateTime.DaysInMonth(year, month) //get actual expiry date Return false // ^ check date format is valid as "MM/yyyy" If (!monthCheck.IsMatch(dateParts) || !yearCheck.IsMatch(dateParts)) // Var dateParts = expiryDate.Split('/') //expiry date in from MM/yyyy If (!cvvCheck.IsMatch(cvv)) // check cvv is valid as "999" Var cardCheck = new monthCheck = new yearCheck = new cvvCheck = new (!cardCheck.IsMatch(cardNo)) // check card number is valid public static bool IsCreditCardInfoValid(string cardNo, string expiryDate, string cvv) The date must be greater than the current actual month and year, and less than 6 years from the current actual month and year. Expiration date must be 2 digits for the month, 4 digits for the year. Security code must be 3 digit numeric (assumed) Credit card number must be 16 digits the first 4 digits must be one of these: 1298, 1267, 4512, 4567, 8901, 8933 You can use the following method, which will validate all the credit card info as per your requirements. Note: I haven't worked on validating the six year requirement. If ((compareYears = 1) || (compareYears = 0 & (compareMonths = 1))) If (Regex.Match(date, expiration date is after current date If (Regex.Match(txtExpiration.Text, month is "01-12" and year starts with "20" if expiration date is in MM/YYYY format Int compareMonths = string.Compare(date, currentDate) Int compareYears = string.Compare(date, currentDate) String currentDate = Regex.Split(("MM/yyyy"), "/") String date = Regex.Split(txtExpiration.Text, "/") If (Regex.Replace(txtCardNumber.Text, "").Length = 16)īool isValid = Regex.Match(txtSecurit圜ode.Text, isValid What would be a better way? And would it be possible to have only one Validate() method instead of a separate one for each? public bool IsValidCard() What I have works, but I think it's kind of messy. I have a text box for each number, txtCardNumber, txtSecuritycode, and txtExpiration.
The guidelines for this assignment areĬredit card number must be 16 digits the first 4 digits must be one of these:Įxpiration date must be 2 digits for the month, 4 digits for the year. Part of it is to validate a user's payment info. I need to create a program for a sandwich shop.