making it as simple as i can....using keyup()
and prop()
.
try this
$(function(){ //<--make sure document is ready
var $btn = $('#buttonID');
$btn.prop('disabled',true); //<---disable the button on default
$('#inputID').keyup(function(){ //<---check if something is typed in input
if($(this).val() != ""){
$btn.prop('disabled',false);
}else{
$btn.prop('disabled',true);
}
});
});
here buttonID
and inputID
is id of button and input respectively..
make sure your are loading the jquery,js script inside <head>
tag
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>