How do I disable the form from submitting? I have tried the following chunk of jQuery with no success - any ideas?
http://pastebin.com/W7hjaSe0
$('#signup').submit(function(){
$('input[type=button]', this).attr('dis开发者_高级运维abled', 'disabled');
});
I am not sure if you are looking for the button to be physically greyed out, or just prevent default action. Here is an example that will run your code on click, grey out the button, and then prevent the default form submission behavior.
$('#signup').submit(function(){
$('input[type=button]', this).attr('disabled', 'disabled').css('opacity',0.5);
return false;
});
I think the problem is your selector, this is not a "button" type
Change
$('input[type=button]', this).attr('disabled', 'disabled');
To
$('input#signup', this).attr('disabled', 'disabled');
A simple return false
should do the trick. If that doesn't work you can always use the preventDefault()
function of event.
精彩评论