I participate in the jQuery learning process and a bit of a pickle with adding and removing a disabled attribute from the html checkbox. I want that when you check the box, you cannot write the address in the text box, otherwise you need to select from the search box. I did this later, but the checkbox is causing my problem. This is my function call. It introduces the function just fine, but does not remove the disabled attributes during validation and throws an error that the addAttr method cannot use to add the disabled one.
jQuery(document).ready(
function () {
jQuery('.InformalContact').live('click',
function (event) {
TestIfInformalContactIsChecked(event);
});
}
);
function TestIfInformalContactIsChecked(event) {
var thisCheck = jQuery(event.target);
if (thisCheck.is(':checked')) {
jQuery("#ContactInfo").removeAttr('disabled');
}
else {
jQuery("#ContactInfo").addAttr('disabled');
}
}
And this is html ...
<div class="TBItemColumn1">
Name: <input id="Name" value="" class="TBFindContact" style="width: 150px;" maxlength="50" type="text" /><br />
<input id="InformalContact" class="InformalContact" maxlength="50" type="checkbox" ClientIDMode="Static" />Informal Contact<br />
<div id="TBContactSearchBox"></div>
Notes:
<br />
<textarea id="Notes" style="width: 280px; height: 20px;"></textarea>
</div>
<div class="TBItemColumn2">
<div class="FloatLeft">
Contact Info:
<br />
<textarea id="ContactInfo" value="" style="width: 280px; height: 70px;" disabled="disabled"></textarea>
</div>
</div>
What did I mess up with setting the disabled attribute on the checkbox?
source
share