<input type="text" name="fx_numm">var extReg1 = /^\d+$/;  //只能是整数数字
var extReg2 = /^\d+(\.\d+)?$/;  //只能是数字
if(!fx_num.match(extReg1)){
alert('发行量必须是整数数字!');
return false;
} if(!fx_num.match(extReg2)){
alert('市场售价必须是数字!');
return false;
}

解决方案 »

  1.   


    <script>
    function chk(s){
      if(s.match(/^\d+\.?[\d]{1}$/g)==null){
        alert('只能为数字或一位小数');
      }
    }
    </script>
    <input type="text" id="point" onblur='chk(this.value);'> 
      

  2.   

      function chk(s){if(s.match(/^\d+(\.[\d])?$/g)==null){ 
        alert('只能为数字或一位小数'); 
      }
      

  3.   


    SORRY,笔误了,应该是:\d*
    if(s.match(/^\d*\.?[\d]{1}$/g)==null){
      

  4.   

    alert(str.match(/^(0|[1-9]\d*(\.\d)?)$/g));
      

  5.   


    <input type="text" id="a">
    <input type="button" value="check" onclick="check()">
    <script>
    function check()
    {
    var reg=/^(0|[1-9]\d*(\.\d)?)$/g;
    if(!reg.test(document.getElementById("a").value))
    {
    alert("必须为整数或以为小数");
    return;
    }
    else
    {
    alert("正确");
    return;
    }
    }</script>
      

  6.   

    应该是
    if(s.match(/^\d\.?[\d]?$/g)==null){
    小数点后面是0或1位。