简体   繁体   English

@之后的HTML电子邮件验证

[英]HTML Email Validation after the @

Is it possible to require a "." 是否可能需要一个“。” after the "@"? 之后 ”@”?

The required validation only forces an email to have some content after the "@", but I would like to require a "." required验证仅强制电子邮件在“ @”之后包含某些内容,但我想输入“。”。 to make the user type in ".com/.org/etc" 使用户输入“ .com / .org / etc”

http://jsfiddle.net/X6Uuc/333/ http://jsfiddle.net/X6Uuc/333/

在此处输入图片说明

If you're relying on the input[type=email] you can also use the pattern attr: 如果您依靠input[type=email] ,也可以使用pattern attr:

I got theRegEx in the example below from the W3C spec for the email input . 在以下示例中,我从W3C规范中获取了RegEx 作为电子邮件输入 The native pattern uses * in the last part then it's not required, I only changed it to + ; 本机模式在最后一部分使用* ,这不是必需的,我只将其更改为+

 <form> <input type="email" pattern="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)+$" required /> <button>Submit</button> </form> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM