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?
I found it. this is the jQuery code:
$(function () {
$('form').submit(function () {
if ($(this).valid()) {
$('input[type="submit"]').attr('disabled', 'disabled');
}
});
});
Try this:
$(document).ready(function(){
$(':submit',this).attr('disabled','disabled');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.