MVC 3: running javascript after validation is complete, but before the actual message?

People,

I have a script for the MVC3 data entry form, which requires the user to confirm something after checking on the client side, but before sending it to the server.

Is there any way to insert any javascript into the sequence of events after the validation structure makes it possible to go back, but before the message appears?

(And, of course, if the user rejects the confirmation, the message should also be canceled.)

Many thanks.

+5
source share
1 answer

.submit , :

$(function() {
    $('form').submit(function() {
        if ($(this).valid()) {
            // client validation passed successfully
        } else {
            alert('there was an error during client validation');
            // cancel the submission of the form
            return false;
        }
    });
});

, , :

var isValid = $('#someFormId').valid();
+11

All Articles