Search code examples
htmlemail-validation

HTML5 Email validation should not allow email without "." example "aaa@aaa"


Basic HTML 5 form, trying to fire HTML 5 email validation which should not allow "aaa@aaa" type of emails, meaning those emails which don't have "." near the end.

so emails like below are correct

[email protected]
[email protected] 

and email like below are incorrect

aaa@aaa

<form>
      <h2>Email Validation</h2>
      <input type="email" value="" placeholder="[email protected]" required />
      <input type="submit" value="Submit" />
    </form>


Solution

  • <input type="email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" />