ionos

Showing posts with label Form Validation Using Regular Expression. Show all posts
Showing posts with label Form Validation Using Regular Expression. Show all posts

Monday, December 30, 2013

Input type validation using Regular Expression

Three letter country code validation

input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code"

Email address validation

^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$

Date validation[yyyy-mm-dd]

^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$
Regular Expression Description
[abc] Any character between the brackets
[^abc] Any character not between the brackets
[0-9] Any digit between the brackets
[^0-9] Any digit not between the brackets
(x|y) Any of the alternatives specified
[a-z] Any character from lowercase a to z
[A-Z] Any character from lowercase A to Z
[^a-zA-Z] Any string not containing any of the characters ranging from a-z and A-Z.
^.{2}$ It matches any string containing exactly two characters.

Featured Post

Payza integration

Payza's Advanced Button in HTML Using simple HTML, you can integrate easily with Payza.Generate buttons and manage payment details f...

Most Popular