I am using cakephp and creating a form
<?php echo $form->create('User', array('action' => 'cancel'));?>
<fieldset>
<?php
echo $form->input('terms', array('type' => 'checkbox', 'label' => __('Terms and Conditions', true)));
echo $form->hidden('security', array('value' => $security));
echo $form->end(__('Cancel My Account', true));
?>
</fieldset>
Now what i want to do is, initially keep the "Cancel My Account" button disabled and only when the checkbox is checked the button should be enabled and hence perform its respective action and similarly vice-versa. I am using the following script to check when the checkbox is checked
<script>
$('document').ready(function(){
$('#UserTerms').click(function() {
var satisfied = $('#UserTerms:checked').val();
if (satisfied != undefined) {
$('.cancel-page div.submit input').removeAttr('disabled');
} else {
$('.cancel-page div.submit input').attr('disabled', 'disabled');
}
});
});
</script>
But this is not working properly. The button is not getting disabled when the checkbox is unchecked. Please suggest how to make it work.
A suggestion, let me know if it works:
you can first define the function and then just call it on document ready.
Hope it helps!