سؤال

I'm using unobtrusive validation in my form in a MVC Project. Should the unobtrusive validation fail I need to popup something in the screen and if it pass I close the form.

Now my question is how can I find out the result of unobtrusive validation on the client side?

هل كانت مفيدة؟

المحلول

You can bind to the form's submit event using jQuery. When the form gets submitted you can check if it is valid, if it isn't then you can popup the dialog.

var form = $('#yourform');
form.submit(function() {
    if(!form.valid()) {
        alert('The form is not valid!!');
    }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top