i am trying to create a form where a text field loads up disabled, and if the user wants to input into this field they have to click a check box. I have this at the moment.
However with what is below the text box loads up enabled and ticking the check box will disable it. How can this be modified so this is reversed. i.e. the text box is first disabled and clicking the check box enables it?
Javascript code
$(document).ready(function () {
$('#testcheckbox').change(function() {
$('#testtextfield').attr('disabled', this.checked);
});
});
HTML code
<input type="checkbox" id="testcheckbox" />
<input type="text" id="testtextfield" />
Thanks.