简体   繁体   English

使用 jQuery 验证 HTML5 email 输入字段

[英]Using jQuery validate with HTML5 email input fields

I'm trying to validate a <input type="email"> using the jQuery validate plugin and the actual validation works fine, but it appears that if incorrect value has been entered and an error message appears, the error message remains after the error has been corrected.我正在尝试使用 jQuery 验证插件验证<input type="email">并且实际验证工作正常,但似乎如果输入了不正确的值并出现错误消息,则错误消息在错误后仍然存在已更正。

Am I doing something wrong or does the validate plugin simply not support type="email" inputs?我做错了什么还是验证插件根本不支持type="email"输入?

The validation plugin can't handle input type of email yet.验证插件还不能处理 email 的输入类型。

Usually, jQuery validation is lazy.通常,jQuery 验证是惰性的。 It won't validate until you try to submit the form.在您尝试提交表单之前,它不会验证。 Or call the isValid() method.或者调用isValid()方法。 Once it has done a validation though, it will become eager: It will validate every field as soon as the field loses focus.但是,一旦它完成了验证,它就会变得急切:一旦字段失去焦点,它就会验证每个字段。

On another note: Shouldn't that be class="email" ?另一方面:不应该是class="email"吗? No too sure about it though, just a comment (which I can't do yet).不过不太确定,只是评论(我还不能这样做)。

You might want to slap some code in here, so we can see what it's actually doing.您可能想在此处添加一些代码,以便我们可以看到它实际上在做什么。

you have to give <input class="email"/>你必须给<input class="email"/>

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

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