jQuery validation: some of the required field not filled but the form can still be submitted

前端 未结 3 1324
挽巷
挽巷 2021-01-26 01:18

I used jquery validation (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) for form validation. The followings are some fragments of my code:

HTML:

<
3条回答
  •  青春惊慌失措
    2021-01-26 02:03

    Instead of:

    // Submit the form by Ajax
    $(document).ready(function() {
      $('.formID').ajaxForm({
        success: function(returnData) {
          $('#content').html(returnData);
        }
      });
    });
    

    Use the submitHandler option of the Validate plugin, like this:

    $("#formID").validate({
        //all your other options
        submitHandler: function(form) {
          $(form).ajaxForm({
            success: function(returnData) {
              $('#content').html(returnData);
            }
          });
        }
     });
    

提交回复
热议问题