Credit Card Validation
Home Up The STACK actions The SMTP actions The MAPI actions The FILE actions The PRINT actions Credit Card Validation The GENERATE Actions

 

If you intend your users to fill in Credit Card details on one of your forms you can have WebCompiler validate the number the user enters using the standard Credit Card modulus checking algorithm. The algorithm supports cards with 13, 15 or 16 digits (Mastercard, Visa, Amex and others).

Please Note: Validating the Credit Card number simply means that it is unlikely the user has "made up" the number, or sinply mistyped it. Only cards whose numbers follow a particular pattern or algorithm are issued by the Card Companies in order to prevent typing or transcription errors.

To have the card number validated all you need do is name the field that the user enters the card number into ValidCreditCard (if you want the field to be a required field), or validcreditcard (if the field can be left blank).

When the form is processed WebCompiler will validate the number. The field must either be blank (if permitted) or must pass the validation test. If not, the user will get a message notifying him that the number is wrong and the form will not be processed further.

You can of course get the user to enter the card number into a field with any other name you like, and it won't be algorithmically validated. You may need to do this if you need to accept obscure cards that don't follow the standard validation rules. (In that case you could maybe consider having two fields, a validated one for Visa/MasterCard/Amex and a second for other cards).

The field below is named ValidCreditCard. Try entering some numbers, both valid and invalid into it. Valid numbers will be accepted, but invalid ones won't.

Enter the Credit Card Number and press the Submit button.

You might like to take a look at the source for this page (right-click and select "View Source") to see how the form fields have been defined.