1

I use this JQuery code to disabled submit button when user click on it, in the form in my MVC3 Project.

$('form').submit(function () {
     $(':submit', this).attr('disabled', 'disabled');
})

I use jquery.validate.js and jquery.validate.unobtrusive.js for validate errors in my form, and when there is a validation error the submit button is disabled. but i want to remove disabled attribute when the validation error occurs. how can i Distinguish the validation error was happened in my code?

1
  • You want to remove the disabled attribute when there are validation errors? So, when do you want to disable the submit button? Commented Aug 12, 2013 at 3:18

2 Answers 2

1

I found it. this is the jQuery code:

$(function () {
        $('form').submit(function () {
            if ($(this).valid()) {
                $('input[type="submit"]').attr('disabled', 'disabled');
            }
        });
    });
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

$(document).ready(function(){
    $(':submit',this).attr('disabled','disabled');
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.