ajax - Trying to disable button when input text field is empty -
i having input text field , button. when text field empty button should disable. when field filled button should enable. tried next code not working help me!
$(document).ready(function(){ $("#wmclrsrch").attr("disabled", "disabled"); if ( $('#search_number').is(":empty") ) { alert ("verdadeiro"); $("#wmclrsrch").attr("disabled", true); } $('#wmsearch').click(function(){ $("#wmclrsrch").attr("disabled", false); $("#wmclrsrch").attr("enabled", true); });
});
the html is:
<form id="form"> <label for="search_number">mobile number:</label> <input id="search_number" type="text" /> <button id="wmclrsrch">clear search</button> </form>
thanks in advance,
check input text using keyup
event :
$('#search_number').keyup(function(){ if($(this).val() != '') { //eneable button here } else { //disable button here } });
ajax jquery
No comments:
Post a Comment