<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="请输入验证码" >

 

posted on 2018-03-15 10:08  刘世涛6192  阅读(1318)  评论(0编辑  收藏  举报