Consider the following script. After validating the script, if they changed their email, I wish to display a dialog prompting them for their password. The server will then only update the database if the password checks out.
The problem is it results in an endless loop since the dialog button submits the form which in turn initiates the dialog. I realize I could just not trigger the dialog if $('#password') is not empty, however, my actual script is more complicated, and it would be "nice" to somehow submit the form and bypass the jQuery validation submitHandler.
Is this possible? If so, how?
var validator=$("#main_form").validate({
rules: {},
messages: {},
submitHandler: function(form) {
if(emailedChanged) {
$("#dialog-password").dialog("open");
}
else {form.submit();}
}
});
$('#dialog-password').dialog({
buttons : [
{
text : 'SAVE',
click : function() {
$('#password').val($(this).find('input').val());
$('#main_form').submit();
}
},
{
text : 'CANCEL',
click : function() {$(this).dialog("close");}
}
]
});
Aucun commentaire:
Enregistrer un commentaire