O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.12. Validation Controls

Whenever we solicit user input, the possibility exists that the user will make an error. If possible, we'd like to catch as many errors as possible before we process the form. For example, if we are accepting credit card information, we can verify that the user has entered a credit card number and expiration date. The credit card number should be all digits, of course, and for Visa and Mastercard it should be 16 digits in length. Beyond that, we can't determine if it represents a valid credit card number. Similarly, the expiration date's month should be between 1 and 12, the year should be equal to or greater than the current year, and so on.

Web Forms provides validation controls to simplify the checking of user input. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required