I can manipulate a control based on the state of another control, as shown in this jsfiddle, where the state of a Checkbox alters the width and background color of a Textbox.
The HTML is:
<input type="checkbox" id="ckbxEmp" >czech Bachs
<input type="text" id="txtbxSSNOrITIN">
The jQuery is:
$(document).on("change", '[id$=ckbxEmp]', function () {
if ($(this).is(":checked")) {
$('[id$=txtbxSSNOrITIN]').css('background-color', '#ffff00');
$('[id$=txtbxSSNOrITIN]').css('width', '24');
} else {
$('[id$=txtbxSSNOrITIN]').css('background-color', 'green');
$('[id$=txtbxSSNOrITIN]').css('width', '144');
}
});
But besides this, what I really need to do is to restrict the number of characters the user enters into the Textbox, according to whether the checkbox's state. How can I do that, preferably with CSS but, if necessary, jQuery?