79811671

Date: 2025-11-06 19:01:44
Score: 0.5
Natty:
Report link

email type inputs don't really need an explicit pattern as they are validated by most modern browsers. However, the rules might not be to your liking. For example: the at least 2 characters after the trailing dot {2,} is not a requirement on Firefox at least. In such cases you might use the pattern attr.

Your pattern is slightly wrong in that you have not escaped the literal -. This leads the pattern analyzer astray. I have added the necessary escapes in my snippet and it seems to work as expected.

Cheers

input {
  display: block;
  margin-bottom: 0.5rem;
}

input:invalid {
  background-color: ivory;
  border: transparent;
  outline: 2px solid red;
}
<form>
  <input type="email" required placeholder="no pattern email" />
  <input type="email" required pattern="[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$" placeholder="pattern email" />
  <input type="password" required minlength="8" placeholder="password"/>
  <button type="submit">Register</button>
</form>

Reasons:
  • Blacklisted phrase (1): Cheers
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Frox