HTML5 allows you to validate an HTML form field using a regular expression. The below HTML code validate an email address against a regex.
<input type="email" name="email" required pattern="[^@]+@[^@]+.[a-zA-Z]{2,6}" />
Test case:
skhsah@gmail.com is valid
skhsah@gmail.com! is invalid
skhsah1@gmail.com is valid
#@%^%#$@#$@#.com is invalid
The validation will appear on blur of the text field.
DEMO
0 Comment(s)