I have the following code which enables a button when the checkbox is checked.
http://jsfiddle.net/ERfWz/1/
The following is a snippet from the code I have in my
You can also set disabled
with true
and false
, so you can simplify it down to:
$(function() {
$('#agree').change(function() {
$('#submit').attr('disabled', !this.checked);
});
});
Test it out here, note there was also some invalid markup going on resulting in some cross-browser inconsistencies, it should look something like this:
<form>
<table>
<tr><td align="center"><input type="checkbox" name="agree" id="agree">I agree Terms and Conditions</td></tr>
<tr><td align="center"><input type="submit" name="submit" id="submit" value="submit" disabled></td></tr>
</table>
</form>
Also the .change() method's a bit better here, to ensure you have the correct state.