Search code examples
htmlvalidationpattern-matchingemail-address

Best form field validation pattern for email at all latest browsers


I want a email validation pattern for all latest browsers. The field type must be in text, not in email.

I tried the different type of patterns like below, but not working in all browsers.

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b
^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

Solution

  • After apply you check in browser "Inspect element" its work on this type

    data-regex="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$"