jQuery - prevent default, then continue default

后端 未结 10 1526
[愿得一人]
[愿得一人] 2020-12-02 16:27

I have a form that, when submitted, I need to do some additional processing before it should submit the form. I can prevent default form submission behavior, then do my addi

10条回答
  •  一整个雨季
    2020-12-02 16:52

    "Validation injection without submit looping":

    I just want to check reCaptcha and some other stuff before HTML5 validation, so I did something like that (the validation function returns true or false):

    $(document).ready(function(){
       var application_form = $('form#application-form');
    
       application_form.on('submit',function(e){
    
            if(application_form_extra_validation()===true){
               return true;
            }
    
            e.preventDefault();
    
       });
    });
    

提交回复
热议问题