客户端验证后,重力表单未提交 [英] Gravity Form is not submitting after client side validations

查看:85
本文介绍了客户端验证后,重力表单未提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将客户端验证放在重力表单上.我是重力形式的新手,我研究并发现重力形式不支持客户端验证.所以我决定自己做.我使用了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
           }
       }
   });
}); 

这篇关于客户端验证后,重力表单未提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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