I am using jquery.validate to validate some input fields, client side prior to submitting to the server. It works great! This particular group of fields appears in a modal, there are two other modals on the page that are popped at different times, depending on what the user clicks on; however, my validation is only on one of the modals and even if that modal is not on the screen, it is preventing my server side submission.
Below is my code in .js for the modal processing, the one I want to supress is "modalChgPass".
(function (window) {
var
$ = window.jQuery,
modalEdit = '#modal-preferences-edit',
modalPreferencesEditOpts = {
autoOpen: true,
modal: true,
resizable: false,
draggable: false,
width: '700',
height: '670',
dialogClass: 'modal',
appendTo: 'form',
close: function () { $(this).dialog('destroy'); }
};
modalChgPass = '#modal-password-change',
modalPasswordChangeOpts = {
autoOpen: true,
modal: true,
resizable: false,
draggable: false,
width: '450',
height: '550',
dialogClass: 'modal',
appendTo: 'form',
close: function () { $(this).dialog('destroy'); }
};
modalActive = '#modal-card-activate',
modalCardActivateOpts = {
autoOpen: true,
modal: true,
resizable: false,
draggable: false,
width: '700',
height: '265',
dialogClass: 'modal',
appendTo: 'form',
close: function() { $(this).dialog('destroy'); }
};
$(document).ready(function () {
$('#btn-modal-password-change').click(function () {
$(modalChgPass).dialog(modalPasswordChangeOpts);
$(modalChgPass).dialog('open');
$('.ui-widget-overlay').click(function () {
$('.ui-dialog-content').dialog('close');
});
return false;
});
$('#chg-Password-btn').click(function () {
$(modalChgPass).dialog(modalPasswordChangeOpts);
$(modalChgPass).dialog('open');
$('.ui-widget-overlay').click(function () {
$('.ui-dialog-content').dialog('close');
});
return false;
});
$('#btn-modal-card-activate').click(function () {
$(modalActive).dialog(modalCardActivateOpts);
$(modalActive).dialog('open');
$('.ui-widget-overlay').click(function () {
$('.ui-dialog-content').dialog('close');
});
return false;
});
$('#btn-modal-preferences-edit').click(function () {
$(modalEdit).dialog(modalPreferencesEditOpts);
$(modalEdit).dialog('open');
$('.ui-widget-overlay').click(function () {
$('.ui-dialog-content').dialog('close');
});
return false;
});
});
window.RCC = window.RCC || {};
})(window);
and here is the .js with the validation:
var $ = jQuery;
$.validator.addMethod('mypassword', function (value, element) {
return this.optional(element) || (value.match(/[a-zA-Z]/) && value.match(/[0-9]/));
},
'Password must contain at least one number.');
$(document).ready(function () {
$("#form1").validate({
rules: {
ChgPass$CurrentPass: {
required: true
},
ChgPass$NewPass: {
required: true,
minlength: 8,
maxlength: 16,
mypassword: true
},
ChgPass$ConfirmPass: {
equalTo: "#ChgPass_NewPass"
}
}
});
});
how do I disable the "modalChgPass" to allow "modalActive" and "modalEdit" to process? Thank you in advance for your assistance. Regards,