Validating Input with the RegularExpressionValidator

Many forms of user input must be entered in very particular formats. For example, when asking for a user's e-mail address, the provided address must follow the following format: one to many alphanumeric characters, @, one to many alphanumeric characters, period, top-level domain name, such as com, net, org, edu, us, uk, fr, and so on.

For the ValidationControlTestBed.aspx ASP.NET Web page, the user is asked for a social security number. In the United States, every citizen is given a social security number, which contains nine digits and is typically written in the form


In order to ensure that a string input meets some specified format, we can use a RegularExpressionValidator, ...

Get SAMS Teach Yourself ASP.NET in 24 Hours now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.