How to disable the submit button on a registration page?
I am building a registration page for my website and i want to disable the submit button till all the fields have been validated using开发者_开发知识库 jQuery and AJAX (I found a way to do this at http://youhack.me/2010/05/04/username-availability-check-in-registration-form-using-jqueryphp/)... Now how do i use this to perform multiple checks and keep the submit button disabled until all the checks have passed?
You would execute the validation code every time a user applies focus to an input, so use something like:
$('input').focus(function(){ /* Validation Code Here */ });
And then if it passes:
$('input[type=submit]').attr('disabled','false');
var $submitButton = $(this, "input[type='submit']");
$submitButton.attr("disabled", "true");
validate();
$submitButton.attr("disabled", "false");
however I think this was bugged in IE ..
to disable
$('#submit_postcode').attr('disabled', 'disabled');
to re-enable
$('#submit_postcode').removeAttr('disabled');
Setting the attribute to any value causes it to be disabled, even .attr('disabled', 'false'), so it has to be removed
精彩评论