Check jquery unobtrusive validation is true by jQuery
Asked Answered
N

2

9

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?

Nica answered 3/5, 2012 at 8:19 Comment(0)
N
20
if ($(this).valid()) {

    var Message = $('#FormConfirmMessage').val();
    return confirm(Message);
}
Nica answered 5/5, 2012 at 5:18 Comment(0)
F
0

if ($(this).validate() = true) // your if condition should be "==". change to like this

if ($(this).validate() == true) 
Favorite answered 3/5, 2012 at 8:45 Comment(1)
That's not worked I just add that script as a simple I think the condition is wrong at allNica

© 2022 - 2024 — McMap. All rights reserved.