0
我已经做了emailid和密码验证的示例代码,但无法验证emailid和密码。任何人都可以帮助我解释这一点吗?emailid和密码验证的简单javascript代码
<html>
<head>
<script language="javascript">
function emailid(){
var a=f.emailid;
if(a==" "){
alert("emailid must not be empty");
}
else if(a.indexof("@")!=-1){
alert("not valid id");
}
else if(a.indexof(".")!=-1){
alert("not a valid id");
}
else
alert("valid id");
}
function pswd(){
var b=f.password;
if(b==" "){
alert("password must not be empty");
}
else if(b.length<6){
alert("not valid password");
}
else
alert("vaild password");
}
</script>
<a href="submit.html"></a>
</head>
<body>
<form>
emailid<input type="text" name="emailid"><input type="button" value="validate" onclick="emailid()"><br>
password<input type="password" name="password"><input type="button" value="validate" onclick="pswd()"><br>
<input type="button" value="submit" onclick="submit.html">
</form>
</body>
</html>
另外其它部分submit.html
<html>
<body>
successfully submitted
</body>
</html>
可变'F'没有任何地方所定义。 'onclick'不是用于导航到成功页面,而是用于执行JavaScript。 – bejado