I have javascript like
just a snipplet …
$dialog.dialog({
title: "Add Link",
buttons: {
"Add Link": function() {
var $this = $(this);
if ($this.valid()) {
alert($this.find("input[name=txtURL]").val());
} else {
$this.find("input.error:first").effect("highlight").focus();
}
},
"Cancel": function() {
$(this).dialog("close");
}
},
open: function() {
$this = $(this);
$this.find("input[name=txtURL]").val("http://").focus();
}
});
as you can see the handler for cancel button is just to close the dialog. why is the validation running when I cancel the dialog? (When you cancel, you can see the flash of the error appearing)
Replace
with
You are validating the dialog, but you must validate just the form you created.