HTML
<input type="text" id="customerProfileID" maxlength="9"/>
<input id="attachTest" class="attachTemplateButton" type="button" value="Attach Template" onclick="attachTemplateCall();"/>
jQuery
$("input").focusin(function() {
$(this).keydown(function() {
$("#attachTest").attr("disabled", true);
});
});
I have this code in jsfiddle too HERE I was trying to make the button back to enable state if the input field is empty. That means, the button should be enable if input is empty and should be disabled if the input have some value. The code works only when there is value, the button is disabled but when I erase the entered value, the button still stays in disabled state. What am I missing here?
$("input").on('keyup', function() {
$("#attachTest").prop("disabled", this.value.length);
});
FIDDLE
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