Email validation in HTML with Regular Expression

0
84
html

This example explains how to validate the email in html page with Pattern attribute in html form using regular expression.

<form action="action.php" method="post">
Email: <input type="text" name="email_address" 
pattern="^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}" required="" title="Please enter valid email address" />
<input type="submit">
</form>

Another way to validate the email address using email input type in html form.

<form action="action.php" method="post">
Email: <input type="email" name="email_address" required="" title="Please enter valid email address"  />
<input type="submit">
</form>

NOTE – In both above examples will work only when you use form tag in your html page.

LEAVE A REPLY

Please enter your comment!
Please enter your name here