I have a Textbox where I need to disable or enable that on some Conditions.
var stat = "any interger"
if (statId != 1) {
$('#<%=txt1.ClientID %>').attr("disabled", "disabled");
}
else {
$('#<%=txtBQty.ClientID %>').attr("enabled", "enabled");
}
This one will work but after disable if the condition returns false also means It won't enable the textbox.
enabled
is not a valid attribute for textbox
es. So the following will have no effect:
$('#<%=txtBQty.ClientID %>').attr("enabled", "enabled");
Instead use
$('#<%=txtBQty.ClientID %>').removeAttr("disabled");
To disable
$('#<%=txt1.ClientID %>').attr("disabled", "disabled");
to enable
$('#<%=txt1.ClientID %>').removeAttr("disabled");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With