Using Regular expressions..
Regular expressions are used to validate the input values, to check it is in correct format as per our requirement. For that we can use the validation controls with expressions.
Just drag and drop the regular expression validator and set the target control ID to the textbox to validate. Then set the regular expression.
Regular expressions are used to validate the input values, to check it is in correct format as per our requirement. For that we can use the validation controls with expressions as below.
Name ^[a-zA-Z''-'\s]{1,40}$
Social
Security
Number ^\d{3}-\d{2}-\d{4}$
Phone
Number ^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[-.]?\d{3}[- .]?\d{4}$
E-mail
^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\ {\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$
URL
^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)* (\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$
ZIP Code ^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$
Password (?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$
Non-
negative
integer^\d+$
Hi
Good tips for regular expression validators