Jquery.valid() does not work after calling a jquery.dialog

29 views Asked by At

I have one form that is in a dialog. When I apply the function:

var form = $('#xxx');
  form.valid()

It works as expected, but this dialog has a button that currently calls another dialog. This second dialog has a form too with its own validation. When I close the second dialog, and then close the first one and open this last again, the validation of the first dialog,I mean "jquery.valid()", does not work. I noticed that the "form.validate.currentelement" of the first dialog, before calling the second dialog has data, but after calling the second one it does not.

part of my code

Landing page

//my first dialog
<div id="dgAddEdit" style="display: none;">
    <div id="dgAddEditContent"></div>
</div>
<!-- my second dialog-->
<div id="dgVendorSearch" title="Vendor Search" class="dialogs"></div>
<div id="dgCollectible">

    @using (Html.BeginForm("", "", FormMethod.Post, new { id = "" }))
    {
        //some html tags for the landing
    }
</div>

Calling the dialogs

 $('#dgAddEdit').dialog("option", "buttons", [
                { id: "SaveButton", text: "Save", click: function () { SaveFeature(); } },
                { id: "CancelButton", text: "Cancel", click: function () { $(this).dialog("close"); } },
                {
                    id: "VendorSearch", text: "Vendor Search", click: function () {
                        $("#dgVendorSearch").dialog('open');
                    }
                }
            ]);

calling the first dialog

 $('#dgAddEdit').dialog("open");
1

There are 1 answers

0
Fermin Pitol On

my problem was that the second dialog had a reference to "jquery.valid" , this deleted all the validation rules of the first dialog, after deleting this reference all the dialogs are working as expected.