I use MVC 3 Model Validation Attributes and jquery unobtrusive to show validation error message also use the script when form submitted return a confirm. So I need to check if the all fields are valid then return Confirm: some thing like the following pseudo-script:
$('div.FormNeedConfirm form').submit(function () {
if ($(this).validate() == true) {
var Message = $('#FormConfirmMessage').val();
return confirm(Message);
}
});
But I don't know what exactly should be in the if condition. What is your suggestion?
I use MVC 3 Model Validation Attributes and jquery unobtrusive to show validation error message also use the script when form submitted return a confirm. So I need to check if the all fields are valid then return Confirm: some thing like the following pseudo-script:
$('div.FormNeedConfirm form').submit(function () {
if ($(this).validate() == true) {
var Message = $('#FormConfirmMessage').val();
return confirm(Message);
}
});
But I don't know what exactly should be in the if condition. What is your suggestion?
Share Improve this question edited Nov 26, 2014 at 14:50 Mark 3,1234 gold badges23 silver badges31 bronze badges asked May 3, 2012 at 8:19 SaeidSaeid 13.6k34 gold badges109 silver badges177 bronze badges2 Answers
Reset to default 20if ($(this).valid()) {
var Message = $('#FormConfirmMessage').val();
return confirm(Message);
}
if ($(this).validate() = true) // your if condition should be "==".
change to like this
if ($(this).validate() == true)