麻煩指點下.因為出現小小的bug.
我寫的那個js是用來檢查是用戶輸入的是否數字,不是的就不通過.因為第一次寫.所以寫得不是太好,有bug,麻煩各位幫我測試下.因為我的js剛學.難免出錯.有請各位指點下.謝謝.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>分頁</title>
</head>
<body>
<form name="form2" action ="javascript:go();">
<br>
<br>
每頁顯示記錄數:
<input type = text name= p>
<input type=submit name = submit onClick="return verify()">
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<th>姓名</th>
</tr>
</body>
</html>
<script language ="javascript">
function go()
{
document.form2.action="testArrayList.jsp";
//document.form2.submit();
}
function isEmpty(val,name)
{
if(val=="")
{
alert("請輸入"+name);
return true;
}
else
{
return false;
}
}
function isAlphabetic(v,nname)
{
var i;
if(isEmpty(v,nname))
return false;
for(i=0;i<v.length;i++)
{
var i =v.charAt(i);
if(!v.match(~/^[0-9]+$/))
{
alert(nname);
return false;
}
}
return true;
}
function verify()
{
if(isAlphabetic(document.form2.p.value,"數位"))
{
document.form2.p.focus();
}
return true;
}
</script>