submit form after validation jquery

前端 未结 5 1197
迷失自我
迷失自我 2021-02-08 02:43

I have following form:

  • Name
5条回答
  •  [愿得一人]
    2021-02-08 03:38

    From your example, I am not clear about the control flow of your page, however, I am assuming you are calling the submit() method somewhere. After you have validated the form and before you submit it, check it's validation with the valid() method. Your code should look something like this:

    $("#form").validate();
    if ($('#form').valid())
        $('#form').submit();
    

提交回复
热议问题