Reputation: 165
could somebody tell me why this simple code doesn't work? I type a random email address with .com at the end and I receive an error that this address doesn't have the right format.
<!DOCTYPE html>
<html>
<body>
<form action="demo_form.asp">
E-mail: <input type="email" name="email" pattern="\.com$">
<input type="submit">
</form>
</body>
</html>
Upvotes: 0
Views: 62
Reputation: 96
Try this pattern. It will validate only .com emails.
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.com$"
Upvotes: 1
Reputation: 1829
There's a problem with your pattern, try using this instead
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
Upvotes: 0
Reputation: 2124
Maybe it works
<form action="demo_form.asp">
E-mail: <input type="email" name="email" pattern="+\.com$">
<input type="submit">
</form>
Upvotes: 3