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