Gravity Form is not submitting after client side validations

心不动则不痛 提交于 2019-12-12 05:44:59

问题


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 ?


回答1:


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
           }
       }
   });
}); 


来源:https://stackoverflow.com/questions/25543935/gravity-form-is-not-submitting-after-client-side-validations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!