![]() In my opinion, #2 is the way to go, you can use regular expressions (as stated above) to pull all spaces, special characters, etc. Be more lenient by assuming their intentions and adjusting their input for them (just be sure to give them a confirmation screen to verify the new input).This requires keeping the user on the page until they get everything right. Be firm about your user input and only accept credit card numbers that are well-formed.I do not think it is an acceptable answer to say "if the user can't figure it out it's their problem." ![]() The problem is solved technically, let's talk about it theoretically. Do absolutely everything possible to validate credit card details prior to submission.Be as forgiving as possible with user input and. ![]() So the short version is two simple rules: That page has a Java implementation of that routine.Įvery website that accepts credit card payment should be doing all of the above as an absolute minimum or you're simply throwing away business as a percentage of your users get frustrated. The credit card number should be verified according to the checksum algorithm mentioned in the page before submitting for processing as part of a standard validation routine. ![]() 14: like a Diners Club card ie 4-6-4 with a space between each group.15: like an American Express card ie 4-6-5 with a space between each group.16: 4 groups of 4 separated by a space.There is every chance the user will give up if it fails 1-2 times rather than wait.Īs for displaying them, that depends on the # of digits: To do otherwise is to provide a really bad user experience. It can take up to 30 seconds (or possibly more) to submit credit card details to a payment gateway so you shouldn't do it until you are sure as you can be that the payment will be accepted. A robust Web application will implement these so you can tell if a credit card number is invalid before you try and use it. That page gives you the rules for the number of digits and the valid prefixes. I suggest you read through Anatomy of Credit Card Numbers. The second thing is that you display the credit card number (even when some of the digits are replaced with X for security reasons) in the correct way. The replaceAll() at the top of this post covers this situation. Which is really important if the user misses or mistypes a digit and needs to find why his or her credit card number failed validation. The first thing is that a CC number with spaces should not be rejected. So I can't tell you exactly how to validate but I can tell you what to validate. Struts 1 for example might or might not use Apache Commons Validator whereas Spring MVC will (probably) use Spring validation and so on. You'll simply annoy your users if you force them to remove spaces you could just as easily do.Īs for how to validate, well that depends on a lot of things, such as which Web framework you're using and what validation options you've chosen. To remove spaces and dashes (some use those too). When you receive a credit card number, it's easy enough to do: String ccNumber = ccNumber.replaceAll("+", "") My view is that any Web app that rejects a credit card number with spaces isn't doing its job.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |