请教JavaScript表单验证??

来源:百度知道 编辑:UC知道 时间:2024/06/15 22:01:42
本人对JavaScript一点也不懂....

用户名:name:uname文本框
密码:name:upass文本框
年龄:name:uage文本框

要求 用户名中不能有数字;密码大于4位且小于8位;年龄大于18且小于70!
请大侠指教,最好JS脚本+Form表单中调用JS 都写!在线等!!!

<script language="javascript">
function check(){
if(!isNaN(document.getElementById('uname').value)){
alert('用户名不能为数字');
return;
}else if(document.getElementById('upass').length<4 || document.getElementById('upass').length>8){
alert('密码长度必须大於4小於8');
return;
}else if(document.getElementById('uage').value<18 || document.getElmentById('uage').value>70){
alert('年龄必须在18到70之间');
}

}
</script>
<body>
<form id="myform" name="myform">
<table align="center">
<caption>表单验证</caption>
<tr>
<td>用户名</td><td><input type="text" name="uname" id="uname" /></td>
</tr>
<tr>
<td>密码</td><td><input type="password" n