问题描述
我正在尝试将客户端验证放在重力表单上.我是重力形式的新手,我研究并发现重力形式不支持客户端验证.所以我决定自己做.我使用了jQuery的验证库,当验证表单时,它尚未提交.我有以下代码:-
I am trying to put client side validation on the gravity forms. I am newbie to gravity forms, i researched and came to know gravity forms do not support client side validations. SO i decided to do it on my own. I used a validation library by jQuery, when the form is validated, it is not being submitted. I have the following code :-
jQuery(document).ready(function(){
jQuery('#gform_49').validate({ // initialize the plugin
rules: {
input_7: {
required: true,
email: true
},
input_8: {
required: true,
url: true
}
},
submitHandler: function (form) {
form.submit();
return true;
}
});
});
一旦验证失败,然后用户输入正确的数据并尝试提交未提交的表单.但是,如果用户第一次提交所有正确的信息,它将起作用.似乎重力形式禁用了两次表单提交.验证后提交表单是否有想法?
Once validation failed and user then inputs correct data and try to submit the form is not being submitted. However if the user submits all the info correct at first time it works. It seems like gravity forms disables form submission twice. Any idea to submit form after validations are true ?
推荐答案
带出整个submitHandler
选项.由于form.submit()
正是插件的默认行为,因此此处不需要.也没有理由将return true
放在任何这些回调函数中.
Take out the entire submitHandler
option. It's not needed here since form.submit()
is exactly the default behavior of the plugin. There is also no reason to put return true
inside any of these callback functions.
jQuery(document).ready(function(){
jQuery('#gform_49').validate({ // initialize the plugin
rules: {
input_7: {
required: true,
email: true
},
input_8: {
required: true,
url: true
}
}
});
});
这篇关于客户端验证后,重力表单未提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!