Given: I have a textbox and a hidden button.
Wanted: When the textbox is neither null nor empty, show the button. When the textbox is null or empty, hide the button.
Question: How should I do this? Should I use jQuery and bind to the textbox's keyup event?
Sure, the keyup
event sounds like a fine idea. You might do something like:
$("textarea").keyup(function() {
if ($(this).val().replace(/ /g, '') == '')
$("#id-of-button").show();
else
$("#id-of-button").hide();
});
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