jQuery UI Dialog with Form Validation Plugin

前端 未结 5 1001
轻奢々
轻奢々 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:22

    Try something like this. Put your form validate stuff outside dialog script or i guess the open callback would work as well.

     buttons : {
           "Cancel" : function() {
                $(this).dialog('close');
            },
            "Submit" : function() {
                var isValid = $("#yourForm").valid();
                if(isValid) {
                    var formData = $("#yourForm")serialize();
                    // pass formData to an ajax call to submit form.
    
                }
               return false;
            }
     },
    

提交回复
热议问题