日期:2014-05-16  浏览次数:20296 次

脚本语言里的一个小问题
由于我没学过jvsp  

大家帮我看下这个脚本语言           <script   language= "JavaScript ">

function   RgTest()   {
        var   numtype=/^[1-9]{1}[1-9]{0,1}$/;
        if(document.order.day.value== " ")   {
                window.alert( "请输入运输天数! ");
                document.order.day.focus();
                return   false;
        }
        if(!(numtype.exec(document.order.day.value)))   {
                window.alert( "天数必须为数字,且开始数字不能为0! ");
                document.order.day.focus();
                return   false;
        }
        return   true;
}    
                </script>  

第一行的   var   numtype=/^[1-9]{1}[1-9]{0,1}$/   是什么意思呢?

------解决方案--------------------
var numtype=/^[1-9]{1}[1-9]{0,1}$/
正则表达式,他的意思是说,匹配开头的数字一次,且必须为1--9之间的数字,匹配末尾的数字0或一次 且为1--9之间的数字