這裏是我的代碼:表單驗證工作不
時後,我進入了姓名和電子郵件形式驗證是不是performing.What我應該做的,以驗證用戶輸入的data.And我就喜歡動命名start.jsp的另一個JSP頁面,當我點擊參與請幫助我擺脫這一點,請告訴我什麼,爲什麼itsn't工作..
<html>
<head>
<title>Aptitude Competition Online</title>
<link rel="stylesheet" type="text/css" href="index.css">
<script language="javascript">
function isEmpty(str) {
if(str=="")
{
return true;
} else return false;
}
function validate() {
var nam = document.form[0].name.value;
var ema = document.form[0].email.value;
if(isEmpty(nam))
{
alert(Name should be filled out");
document.form[0].name.focus;
return false;
}
else if(isEmpty(ema)
{
alert(E-mail should be filled out");
document.form[0].email.focus;
return false;
}
else {
return true;
}
}
</script>
</head>
<body>
<div id="header1">
<font id="font1">Aptitude Quiz</font>
</div>
<div id="email">
<div id="inside">
<font id="font2">Welcome to Aptitude Quiz</font><br><br><br>
<form name="form">
Name : <input type="text" name="name"><br><br>
E-mail : <input type="text" name="email"><br><br>
<input name="Participate" type="button" value="Participate" onClick="validate()"><br><br>
</form>
</div>
</div>
<div id="footer">
Contact Us : [email protected]
</div>
</body>
</html>
什麼錯誤,你在控制檯中得到些什麼? –
有幾個語法錯誤,缺少引號,'document.forms'等。 – adeneo