Html5 pattern attribute not matching for email([email protected])

KVK_cool picture KVK_cool · Jul 4, 2013 · Viewed 29.2k times · Source

I am new to HTML5...

Here i am having some problem with email pattern attribute...

1)if i am giving the input like [email protected]... in email field..

2)it's not accepting value and showing "Pattern not matched"..

Help me to fix this....

Here is the snippet of Html

<form name='f1' method="POST" action=""  >     
  <div id="fp">


        <span style="margin-left:-50px">Email:</span>&nbsp;&nbsp;
        <span><input  class="input" type="email" name="Email" placeholder="Enter mailID" required pattern="^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$" ></span><br>


         <input type="submit"  name="submit" value="submit">

   </div>
  </form>    

Any suggestions are acceptable....

Answer

Ashish Chopra picture Ashish Chopra · Jul 4, 2013

this should be correct pattern

[^@]+@[^@]+\.[a-zA-Z]{2,6}

yes you forgot to consider lower case.

you can refer this document for more details

html5-form-validation-with-regex