How to force form client-side validation in or before $.ajax()

后端 未结 4 1803
难免孤独
难免孤独 2020-12-19 00:34

I have a form and unobtrusive validations are enabled. By default in submit method client side validation gets triggered and (if you have any errors) the form looks like thi

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 00:58

    You must force the form to validate before checking if it is valid. Something like this:

    var form = $( "#myform" );
    form.validate();
    if (form.valid()) {
        // ...
    }
    

提交回复
热议问题