各位兄弟,我想限制输入的数据为数值型,但我我即使输入了如67,也会提示输入数值,哪位兄弟能赐教,我不胜感激!!!!!!!!!!
<form method="POST" action="" name="form1"  >
    <input type="text" name="数量" size="3">
    <input type="submit" class= "button1"  value="提交" onclick="return check()">
</form>
 <script language="JavaScript">
<!--
//检查用户填写内容的格式是否正确
function check()
{
      if(typeof(document.form1.数量.value!="number")) 
     { document.form1.数量.focus();
        alert("请输入数值!");
   return false;  }</script>

解决方案 »

  1.   

    <script language="JavaScript"> 
    <!-- 
    //检查用户填写内容的格式是否正确 
    function check() 

        if(isNaN(document.form1.数量.value)
        { document.form1.数量.focus(); 
            alert("请输入数值!"); 
         return false;} </script> 
      

  2.   

    <input type="text" name="inputNum" size="3"> name的值尽可能用英文字符
      

  3.   

    value 都是字符串!!!用正则吧!L@_@K
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
      <script type="text/javascript">
      <!--//检查用户填写内容的格式是否正确 
    function check() 
    {
    // 整数或小数。
    var rgexp = /^\d*\.?\d*$/g;    if(!rgexp.test(document.form1.数量.value)) 
        {
    document.form1.数量.focus(); 
            alert("请输入数值!"); 
    return false;
    }
    }
      //-->
      </script>
    <form method="POST" action="" name="form1"  > 
        <input type="text" name="数量" size="3"> 
        <input type="submit" class= "button1"  value="提交" onclick="return check()"> 
    </form> 
     </body>
    </html>
    Web 开发常用手册JScript语言参考.rar
    http://download.csdn.net/source/308916DHTML参考手册.rar
    http://download.csdn.net/source/308913样式表中文手册.chm
    http://download.csdn.net/source/304124
      

  4.   

    <form method="POST" action="" name="form1"  > 
        <input type="text" name="数量" size="3"> 
        <input type="submit" class= "button1"  value="提交" onclick="return check()"> 
    </form> 
    <script language="JavaScript"> 
    <!-- 
    //检查用户填写内容的格式是否正确 
    function check() 

          if(isNaN(Number(document.form1.数量.value))) 
        { document.form1.数量.focus(); 
            alert("请输入数值!"); 
      return false;  
      } 
    }
    </script> 
      

  5.   


    isNaN(null) == false;
    isNaN("")   == false;
      

  6.   

    正则表达式试试
    下面的代码只能输入数值,拷贝试试
    <input type="text" name="year" id="year" value="" class="inp ipt-normal" onFocus="this.className='inp ipt-focus'" maxlength="4" style="width:80px" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /> 年 <input type="text" name="month" id="month" value="" class="inp ipt-normal" onFocus="this.className='inp ipt-focus'" maxlength="2" style="width:50px" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /> 月 <input type="text" name="day" id="day" value="" class="inp ipt-normal" onFocus="this.className='inp ipt-focus'" maxlength="2" style="width:50px" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /> 日
      

  7.   

    3楼的兄弟,4楼的10分本来是加给你的,还有办法改吗???实在sorry!