RegularExpressionValidator is one of most useful validation controls which automatically provides both client-side and server-side validation. It is simple and straigforward to be invoded. All what you need it to supply an appropriated regular expression. And the web server control will hanlde both client-side and server-side validations for you. As long as you are familiar with the way to construct a regular expression, you will be able to validate lots of inputs by using RegularExpressionValidator. For instance, Email, URL, Phone #, Postal Code, SIN, Strong Password and etc...
Web Server Control: RegularExpressionValidator
NameSpace: System.Web.UI.WebControls
NameSpace: System.Web.UI.WebControls
|
|
|
Demo #1: Validate Canadian Postal Code: [a-zA-Z]\d[a-zA-Z]\s?\d[a-zA-Z]\d"
Demo #2: Validate USA Zip Code: \d{5}(-\d{4})?
Demo #4: Validate Internet Email Address: \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Demo #5: Validate Internet URL: ([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
Demo #6: Validate North America Phone Number: \d{3}-?\d{3}-?\d{4}
Demo #7: Validate USA Social Security Number: \d{3}-?\d{2}-?\d{4}
Demo #8: Validate Canadian Social Insurance Number: \d{3}-?\d{3}-?\d{3}
Demo #2: Validate USA Zip Code: \d{5}(-\d{4})?
Demo #4: Validate Internet Email Address: \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Demo #5: Validate Internet URL: ([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
Demo #6: Validate North America Phone Number: \d{3}-?\d{3}-?\d{4}
Demo #7: Validate USA Social Security Number: \d{3}-?\d{2}-?\d{4}
Demo #8: Validate Canadian Social Insurance Number: \d{3}-?\d{3}-?\d{3}
No comments:
Post a Comment