<input class="lineHeight-30" type="text" onkeyup="value=value.replace(/[^\d$]/ig,'')" placeholder="请输入验证码" >
或者
<input id="numberbox" class="lineHeight-30" type="text" placeholder="请输入验证码" > function onlyNumber(event){ var keyCode = event.keyCode; if(keyCode<48 || keyCode>57){ event.keyCode = 0; } } $(function(){ $("#numberbox").keydown(onlyNumber); });
或者
<input class="lineHeight-30" type="nuber" placeholder="请输入验证码" > <input class="lineHeight-30" type="tel" placeholder="请输入验证码" >