需要制作一个智能表单,但是一直达不到要求,请问是哪里的代码出了问题?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script>
<!--
function registerform(){
if(nameCheck()&&passwordCheck()&&emailCheck())
return true;
else
return false;
}
function nameCheck(nameId){
var name=document.myform.txtName.value;
if(name.length!=0){
for(var i=0;i<name.length;i++){
var str=nameId.toLowerCase().charAt(i);
if(!((str>="a"&&str<="z")&&(str>="0"&&str<="9")||str=="_")){
console.log("会员名输入格式不正确");
return false;
}
}
return true;
}
}
function passwordCheck(){
var password=document.myform.txtPassword.value;
if(password.length<6){
console.log("密码必须多于6个字符。\n");
document.myform.txtPassword.value="";
document.myform.txtPassword.style.color="red";
return false;
}
return true;
}
function emailCheck(){
var email=document.myform.txtEmail.value;
if(email.indexOf(".",0)==-1){
console.log("电子邮件格式不正确\n必须包含字符.");
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<form name="myform" onsubmit="registerform( );" method="post">
<table>
<tr>
<td>会员名:</td>
<td><input type="text" id="txtName" required>(可包含 a-z、0-9 和下划线)</td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="txtPassword" required>(至少包含 6 个字符)</td>
</tr>
<tr>
<td>邮箱:</td>
<td><input type="email" id="txtEmail" required>(至少包含 6 个字符)</td>
</tr>
<tr>
<td>
<input type="reset" value="重置" id="txtReset">
</td>
<td>
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/236310536936129.png "#left")
<input type="submit" value="登录" id="txtRegister">
</td>
</tr>
</table>
</form>
</body>
</html>