<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>checked date</title>
</head>
<script>
function checkType()
{
userName=document.fm.username.value;
passWord=document.fm.password.value;
age=document.fm.age.value;
String errorChar=";:'.,?!@#$%^&*<>{}[]=-_+|~`";
String number="0123456789";
for(int i=0;i<userName.length();i++)
{
if(!errorChar.indexOf(userName.charAt(i))==-1)
{
alert("姓名填写不正确!!!");
return false;
}
if(!errorChar.indexOf(userName.charAt(0))==-1)
{
alert("第一个不能为数字!!");
return false;
}
}
if(age.length!=2||isNaN(age)||parseInt(age)<20||parseInt(age)>50)
{
alert("你的年龄不符合我们的要求!");
return false;
}
return true;
}
</script>
<body>
<h3>the from will be checked by server!</h3>
<form name="fm" onSubmit="return checkType();">
<p>userName:<input name="username" type="text"></p>
<p>passWord:<input name="password" type="password"></p>
<p> age :
<input name="age" type="text"></p>
<p><center><input type="submit" value="提交">
<input type="reset" value="重置"> </center></p>
</form>
</body>
</html>
哪位指点下小弟。。我刚学jsp。。搞了半天都不知道错在什么地方。。。谢谢