I'd like to add basic form validation to a UI Dialog using the standard.. http://bassistance.de/jquery-plugins/jquery-plugin-validation/ Where this call works elsewhere (I can't make it work within a Dialog).. $("#FY12-Q1-AM-ALL-ECMC-VML-ProfilingForm").validate();
The Dialog Submit doesn't seem to catch the validation.. What approach have you guys used to solve the problem? I figure it must be a f开发者_如何学JAVAairly common one -
thanks
$('#lowValueSurvey').dialog({
autoOpen: false,
modal: true,
width: 900,
resizable: false,
show:"puff",
hide:"puff",
close:"puff",
open: function(event, ui) {
performElqLookups('#FY12-Q1-AM-ALL-ECMC-VML-ProfilingForm');
},
buttons: {
'Submit': function() {
$("#FY12-Q1-AM-ALL-ECMC-VML-ProfilingForm").validate();
$.ajax({
type: "POST",
async: false,
url: $("#FY12-Q1-AM-ALL-ECMC-VML-ProfilingForm").attr('action'),
data: $("#FY12-Q1-AM-ALL-ECMC-VML-ProfilingForm").serialize()
});
setCookie(lowValueCookieName, -1, 1000);
$(":button:contains('Submit')").hide();
$("#lowValueSurvey").load('/longstoryshort/forms/confirmation.html');
$("#lowValueSurvey").dialog({
close: {effect: "fadeOut", duration: 5000}
});
}
}
});
I believe validate only initializes the validation. You have to call .valid() to check for validation. You could try doing return false; to stop the function propagation if .valid() returns false.
精彩评论