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>
答案 0 :(得分:3)
也许它有效
<form action="demo_form.asp">
E-mail: <input type="email" name="email" pattern="+\.com$">
<input type="submit">
</form>
答案 1 :(得分:1)
尝试这种模式。它只会验证.com电子邮件。
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.com$"
答案 2 :(得分:0)
您的模式存在问题,请尝试使用此模式
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"