jQuery: Stop submitting form, perform script, continue submitting form?

前端 未结 8 1067
遇见更好的自我
遇见更好的自我 2021-02-04 02:09

I have a form, and when I submit him I execute multiple script. Here is my code:

$(\"#RequestCreateForm\").submit(function (e) {
    if ($(\"#RequestCreateForm\"         


        
8条回答
  •  渐次进展
    2021-02-04 02:48

    
    $("#RequestCreateForm").submit(function (e) {
        if ($("#RequestCreateForm").validate().checkForm() === false) { 
           e.preventDefault(); 
           //form was NOT ok - optionally add some error script in here
    
           return false; //for old browsers 
        } else{
           //form was OK - you can add some pre-send script in here
        }
    
        //$(this).submit(); 
        //you don't have to submit manually if you didn't prevent the default event before
    }
    

提交回复
热议问题