Regular expression for validating name in asp net
For this reason, in the past, many developers decided to add all their form validation logic exclusively to server-side code.
Because server-side code functions correctly with any browser, this course of action was safer.
Traditionally, Web developers have faced a tough choice when adding form validation logic to their pages.
You can add form validation routines to your server-side code, or you can add the validation routines to your client-side code.
Regex Code: The Regular Expression below validates the username format.
^[a-z A-Z0-9_]$ Scope: So while creating a new user for a website you can validate the username string with the following business logic: 1) User name must be between 5 to 20 characters. As you can see this is a very basic code to evaluate simple username for your website.
In particular, the client-side scripts discussed in this chapter do not work with any version of Netscape Navigator. If, for whatever reason, you want to disable client-side form validation, you can do so by adding the following directive at the top of your page: This directive disables client-side form validation.
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.
The Regular Expression Validator is a bit more difficult to write about, because it requires knowledge of Regular Expressions to really use it.
However, Regular Expression Validator is one of the most useful validators, because it can be used to check the validity of any kind of string.