<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GBK">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script>
function a(){
//regexp=/^[0-9]*$/;
regexp=/^[1-9]\d{1,}$/;
pageno=document.all.pagenum.value;
if(!regexp.test(pageno)){
alert("please数字");
return false;
}else{
alert(true);
}
}
</script>
</head>
<body>
<form onsubmit="a();">
<input type=text name=pagenum><br>
<button onclick="a();">click me</button>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GBK">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script>
function a(){
//regexp=/^[0-9]*$/;
regexp=/^[1-9]\d{1,}$/;
pageno=document.all.pagenum.value;
if(!regexp.test(pageno)){
alert("please数字");
return false;
}else{
alert(true);
}
}
</script>
</head>
<body>
<form onsubmit="a();">
<input type=text name=pagenum><br>
<button onclick="a();">click me</button>
</form>
</body>
</html>
真是气死人。
文本框要这样写:<input type="text" ID="abc" OnKeyPress="return event.keyCode>=48&&event.keyCode<=57">
不敢居功,答案来自:
http://access911.net/ocr/doc1.asp?mode=a&bid=005202&aid=5495433
if(textbox.value==num.toString()){
if(num<=10){
alert("输入要大于10!")
}else{
alert("验证成功!")
}
}else{
alert("请输入数字!")
}
而是OnkeyDown="return a()",然后错误就返回return false。
唉!真高兴,今天又有进步了,为自己喝彩,每天进步多一些!