jQuery UI Dialog with Form Validation Plugin

前端 未结 5 995
轻奢々
轻奢々 2021-02-09 22:41

I am currently using the bassistance validation plugin for my forms. And I am using a pop-up modal dialog box to house a form that needs to be validated, but for some reason it

5条回答
  •  清酒与你
    2021-02-09 23:42

    I solved a similar issue in 3 steps:

    1. Attaching the validator to the form:

      $('#your-form-id').validate();
      
    2. When the Save button of your modal form is clicked, submit the form (the validator will be triggered):

      buttons: {
        "Save": function() {
          $('#your-form-id').submit();
        },
      
    3. Move the submit logic to the validator submitHandler:

      $('#your-form-id').validate({
        submitHandler: function(form) {
          // do stuff
        }
      });
      

提交回复
热议问题