hey, i have a registration form on a page where the submit button's disable attribute is set to true on pageload. In this form there is an "I accept these terms..." checkbox that must be checked for the form to go through successfully. I'm trying to set the submit button's disabled attribute to false when the checkbox is checked, and again back to true if the checkbox is checked again. This way, there is no way to submit the form if that checkbox is unchecked (atleast with javascript enabled, I have set up server side checks for all of this as well). Here is the javascript I am using:
Is there anything inherently wrong with this code? I can't seem to get it to work. Maybe I am approaching this the wrong way, I still don't have too much experience with javascript/jquery.
Let me know if you can help,
thanks!
Code:
$('div#register input#terms').change(function() {
var disabled=$('div#register input#submit').attr('disabled');
if(disabled=='false') {
$('div#register input#submit').attr("disabled", true);
}
if(disabled=='true') {
$('div#register input#submit').attr("disabled", false);
}
});
Is there anything inherently wrong with this code? I can't seem to get it to work. Maybe I am approaching this the wrong way, I still don't have too much experience with javascript/jquery.
Let me know if you can help,
thanks!