onKeyUp="value=value.replace(^([1]?[1-9]?[0-9]{1})([\.]?\d?)?$ ,'')"
这里我想验证成绩````但是为什么我还是能输入中文,英文还有数字呢``?

解决方案 »

  1.   


    $iScore = '1313';
    preg_match('/[\d]{0,5}/i', $iScore, $aMatches);
    print_r($aMatches);
      

  2.   

    写个函数不行吗,我随便写一个,不知道有没有用:
    function ckscroe(num){
    var scroe=/^[0-9]{2,3}$/;
    if(!scroe.exec(num)){alert('请输入0-9数字');return false}
    return turn;
    }
      

  3.   

    貌似好像用正则表达式不能写的吧,我刚刚用JS写了一个验证方法,只能在提交的时候做判断,不能在按钮的onkeyup事件里面去实现,要是能高手能实现这个方法,也请告知,谢谢
      

  4.   

    只能输入数字
    <input type=text onKeyUp="this.value=this.value.replace(/[^\d]/g ,'')">以后这种非php的问题请到“WEB开发”中的相应版块发问
      

  5.   

    //js 代码
    function check(value){
        var reg = '/^[0-9]*$/';
        if(!reg.exec(value)){
            alert('只能输入数字!');
        }
        value="";
    }
    //html 
    <input type="text" name="" value="" onKeyUp="check(this.value)">