<input onpropertychange="if (/\D/g.test(value)) value=value.replace(/\D/g,'')" name="tttt" type="TEXT" maxlength="18" size="18">

解决方案 »

  1.   

    请问楼上onpropertychange是什么意思?
      

  2.   

    我原来是这样判断的 if (value.search(/^[0-9]+$/)==-1) 
    但它只能判断整数。
      

  3.   

    onpropertychange 改变内容触发,改变属性值也会触发
      

  4.   

    yslcuk(yl) 你的方法我式过了,也只能输入整数,但是小数就输入不了。
      

  5.   

    alert(/^(-|\+)?(\d+\.\d+)$/.test("1212.12"));
      

  6.   

    那改下
    <input onpaste="return false" onkeyup="this.value=this.value.replace(/[^\d\.]/g,'');"  name="money" type="TEXT" maxlength="10" size="18" title="此处可以不输入小数点和小数点后两位" >
      

  7.   

    Expression(NO3):  ^[-+]?\d*\.?\d*$  Rating: 4 [ Rate]  
    Description:   Matches any floating point numer/numeric string, including optional sign character (+ or -). Also matches empty strings.  
    Matches:  [123], [+3.14159], [-3.14159]  [ More Details]  
    Non-Matches:  [abc], [3.4.5], [$99.95]  [ Test Expression]  
    Submitted By:  1  
      

  8.   

    好像都不行,我是这样写的
             if (value.search(/^\d{0,}[.]?\d{1,}$/)==1) 
                 {
                      alert(message+"!\n"); // 判断不能为空
                      name.focus();
                     name.select();
                      return false;
                 }
      

  9.   

    "^\\d+$"  //非负整数(正整数 + 0) 
    "^[0-9]*[1-9][0-9]*$"  //正整数 
    "^((-\\d+)|(0+))$"  //非正整数(负整数 + 0) 
    "^-[0-9]*[1-9][0-9]*$"  //负整数 
    "^-?\\d+$"    //整数 
    "^\\d+(\\.\\d+)?$"  //非负浮点数(正浮点数 + 0) 
    "^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮点数 
    "^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"  //非正浮点数(负浮点数 + 0) 
    "^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //负浮点数 
    "^(-?\\d+)(\\.\\d+)?$"  //浮点数 
    "^[A-Za-z]+$"  //由26个英文字母组成的字符串 
    "^[A-Z]+$"  //由26个英文字母的大写组成的字符串 
    "^[a-z]+$"  //由26个英文字母的小写组成的字符串 
    "^[A-Za-z0-9]+$"  //由数字和26个英文字母组成的字符串 
    "^\\w+$"  //由数字、26个英文字母或者下划线组成的字符串 
    "^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$"    //email地址 
    "^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$"  //url
      

  10.   

    <input onKeyUp="value=value.replace(/[^\d\.]/g,'')">