Preventing a form from submitting in jQuery Validate plugin's submitHandler function

后端 未结 8 1663
花落未央
花落未央 2020-12-08 07:24

I am using jQuery with the validate plugin at http://docs.jquery.com/Plugins/Validation/validate

I want to prevent the form from submitting after its validation and

8条回答
  •  青春惊慌失措
    2020-12-08 08:06

    I fixed this way. A patch for a jQuery Validation Plugin bug that it's not fixed even on v1.19.0

    $('#save_edit_user').on('click', function () {
        var isValid = $("#edit_user").validate().form() && $("#edit_user").validate().element("#edit_user_email");
        //check current ajax call by $.active 
        //the form is not submitted before 0 ajax is running
        if (isValid && $.active == 0){
         // my save logic
    
        }
    });
    

提交回复
热议问题