当前位置: 代码迷 >> Web前端 >> 禁止输入小于零的数,最小为1
  详细解决方案

禁止输入小于零的数,最小为1

热度:114   发布时间:2012-11-06 14:07:00.0
禁止输入小于0的数,最小为1
<html>

<head>

<title>禁止输入小于0的数,最小为1</title>

<script type="text/javascript">

function CheckInputInt(oInput) { 
   if ('' != oInput.value.replace(/\d/g,'')) 
   {
     oInput.value = oInput.value.replace(/\D/g,''); 
   }
   if(parseInt(oInput.value)<0.1){
      oInput.value="1";
   }

 }

</script>

</head>

<body>

禁止输入小于0的数<input  type="text" name="num" onkeyup="CheckInputInt(this);" onblur="CheckInputInt(this);" onafterpaste="CheckInputInt(this);" />

</body>

</html>

?

  相关解决方案