bassistance jQuery表单验证插件-提交前发送电子邮件错误 [英] bassistance jQuery form validation plugin - email error before submission

查看:93
本文介绍了bassistance jQuery表单验证插件-提交前发送电子邮件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此插件: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

I'm using this plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

用于JQuery表单验证.除电子邮件字段外,其他所有东西都运行良好.当我开始在该字段中输入内容时,请输入有效的电子邮件地址".即使到目前为止我输入的内容是正确的,也会出现一条消息.

For JQuery form validation. Everything is working great except for the email field. As soon as I start typing in that field, the "Please enter a valid email address." message appears, even though what I've typed so far is correct.

在文档中( http://docs.jquery.com/Plugins/Validation )它说:

在将字段标记为无效之前,验证是惰性的: 首次提交表单时,用户可以通过 字段而不会收到烦人的消息-他之前不会被打扰 他有机会实际输入正确的值"

"Before a field is marked as invalid, the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages - he won't get bugged before he had the chance to actually enter a correct value"

但这似乎在电子邮件字段中没有发生.

But this doesn't seem to happen for the email field.

这个问题也可以在作者的演示中看到: http://jquery.bassistance.de/validate/demo/

This problem can also be seen in the author's demo: http://jquery.bassistance.de/validate/demo/

此行为是否有选项/解决方法?

Is there an option/workaround for this behaviour?

推荐答案

"在将字段标记为无效之前,验证是惰性的:在首次提交表单之前,用户可以通过以下方式进行制表 字段而不会收到烦人的消息-他之前不会被打扰 他有机会实际输入正确的值"

"Before a field is marked as invalid, the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages - he won't get bugged before he had the chance to actually enter a correct value"

但这似乎在电子邮件字段中没有发生.

But this doesn't seem to happen for the email field.

不仅使用email规则.您可以在minlength规则上看到相同的行为.

It's not just with the email rule. You can see the same behavior on the minlength rule.

http://jsfiddle.net/f3sxF/

此行为是否有选项/解决方法?

Is there an option/workaround for this behaviour?

您可以使用似乎可以解决此问题的预发行版本.但是,您可以使用onkeyup回调函数的修改版本...

You could use the pre-release version which seems to fix this. However, rather than risking new bugs by the use of a "pre-release" version of the plugin on your production site, you could simply use a modified version of the onkeyup callback function...

$('#myform').validate({
    onkeyup: function (element, event) {
        if (event.which === 9 && this.elementValue(element) === '') {
            return;
        } else if (element.name in this.submitted ) {
            this.element(element);
        }
    },
    // your other options
});

使用上述方法,所有onkeyup验证都将被忽略,直到第一次提交表单,或者直到用户从包含输入数据的字段中跳出为止.

Using the above, all onkeyup validation is ignored until the form is submitted for the first time, or until the user tabs out of a field which contains entered data.

演示: http://jsfiddle.net/wNj4n/

这篇关于bassistance jQuery表单验证插件-提交前发送电子邮件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆