im using jquery with asp.net mvc.
Im doing something like this so that the submit button becomes disabled when clicked.
but if there are validation errors i dont want it to be disabled.
$('form').submit(function () {
if ($('form').valid()) {
$('input[type=submit]', this).attr('disabled', 'disabled');
}
});
this makes it disabled, but even if there are validation errors.
whats wrong?
EDIT: i’ll try again after my first screw up 😛
Maybe there are other forms on the page, and it’s validating the wrong one?
oh and did you $(‘form’).validate() to enable validation (which I would guess is called automatically by MVC if you’re using MVC’s validation, but I’m not 100% sure about that)?