Regular expression for validating name in asp net
Since Regular Expressions are beyond the scope of this tutorial, I won't try to explain it, other than it simply tells the validator that a value of 4 digitgs is acceptable, and nothing else.
You can use the Regular Expression Validator for almost everything, for instance validating an e-mail or an URL.
Try switching to Design view and select the Regular Expression Validator on your page.
Now have a look in the Properties tab of Visual Studio.
The problem, however, is that it does not work with all browsers.
Not all browsers support Java Script, and different versions of browsers support different versions of Java Script, so client-side validation is never guaranteed to work.
Here is an example where we require a 4 digit number - nothing else is acceptable: The only new attribute we use, is the validationexpression.
This attribute simply holds the Regular Expression which should be used to validate the field.
For example, if a user neglects to enter a value in a required form field, you can instantly display an error message without requiring a roundtrip back to the server. It looks great and creates a better overall user experience.2) User name can have lowercase and uppercase characters. Implementation: HTML code: Code Behind: using System. Regular Expressions; protected void btn Validate_Click(object sender, Event Args e) Now just run the application an verify the results.