Skip to content Skip to sidebar Skip to footer

Hide Checkbox If Textbox Has Text, Jquery

When the document loads I am trying to css hide a check box only if a textbox has text. Instead all the check boxes are being hidden, even if the text boxes are empty. Any help

Solution 1:

Hm, try

functioncheck() {
 if(document.getElementById('yourTextFieldId').text != null) {
 document.getElementById('yourCheckboxId').disabled = true;
 }
 else {
 document.getElementById('yourCheckboxId').disabled = false;
 }
 }

Solution 2:

you can use something like this:

$('input:checkbox').each(function () {
    if (!this.value || !$(this).text() ) $(this).hide();
});

here it will hide each checkbox as soon as there is no value or no text.

Solution 3:

Change your if statements to use val().

$("#<%=FinishDateSrvcTXT.ClientID%>").val().length > 0){
   $("#<%=FinishFillCHK.ClientID%>").css('display', 'none');
}

Post a Comment for "Hide Checkbox If Textbox Has Text, Jquery"