这个是我刚刚邦别人做的判断输入的时候是11位的数字
<script>
function t_change(){
var t;
t=t1.value
if(t.length!=11){
alert("输入的不是11位!");
return;
}if (!t.search("^[0-9]*[1-9][0-9]*$"))
alert("格式正确");
else
alert("格式错误");
}
</script>
<input type=text id=t1>
<input type=button onclick="t_change()" value=ok>

解决方案 »

  1.   

    <script>
    function t_change(){
    var t;
    t=t1.value
    if(t.length!=5){
    alert("输入的不是5位!");
    return;
    }if (!t.search("^[0-9]*[1-9][0-9]*$"))
    alert("格式正确");
    else
    alert("格式错误");
    }
    </script>
    <input type=text id=t1>
    <input type=button onclick="t_change()" value=ok>
    </script>
    <input type=text id=t1>
    <input type=button onclick="t_change()" value=ok>
      

  2.   

    if(strlen($regist_mk_num)!=5 || is_int($rigist_mk_num)==false)
    echo "不是5位数字";笔误!
    regist_mk_num
    rigist_mk_num