正则表达限制为正整数
时间:2010-10-09 来源:The Coder.
代码
<html>
<head>
<script language="javascript" type="text/javascript">
var G=document.getElementById;
function checkNumber(){
var reg = /^(?:0|[1-9][0-9]?|100)$/;
var strNumber = G("txtNumber").value;
alert(reg.test(strNumber))
}
</script>
</head>
<body >
<input type="text" value="" id="txtNumber" title="Please enter a number witch between 0 and 100 ..">
<button onclick="checkNumber();">CheckNumber</button>
</body>
</html>
相关阅读 更多 +