$('#name').change(function(event) {
/* Act on the event */
var txtVal=$(this).val();
if (txtVal=="") {
$('#btn').attr('disabled',"true");
}else{
$('#btn').attr('disabled',"false");
}
});
或者:
<input type="text" id="inpnumber" name="inpnumber" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" />
<input type="button" language="javascript" onclick="return btnapply()" id="btn" name="btn"
value="提 交" />
<script type="text/javascript" language="javascript">
function btnappley()
{
var inpnumber=document.getElementById("#inpnumber").val();
if(inpnumber=="")
{
alert("为空则按钮还能显示")
}
else{
$('#inpnumber').attr('disabled', "true");
}
}
</script>