你能幫我用這段代碼嗎?我的Javascript不執行,有誰知道爲什麼?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Daily News</title>
<script type="text/javascript" src="Scripts.js">
</script>
<link href="homepage.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="body">
<div class="header">
<a href="#" title="Home"><img id="header-image" src="news_logo.png" /></a>
<form id="login-form" action="customerLogin.html" method="post" onsubmit="return validate(this)">
<table>
<tr>
<td><label for="loginid">Login:</label></td>
<td id="login-form"><input id="login-boxes" type="text" id="loginid"></td>
<td><label for="pword">Password:</label></td>
<td id="login-form"><input id="login-boxes" type="password" id="pword"></td>
</tr>
<tr>
<td></td>
<td id="login-buttons"><input type="submit" value=" Sign In ">
<input type="reset" value="Clear form">
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
我的JavaScript:
function validate(loginForm)
{
var booValid = true;
var strErrorMessage = "";
var minLength=5;
var maxLength=10;
if(loginForm.pword.value.length < minLength)
{
strErrorMessage = "password must at least 5 characters\n";
booValid=false;
}
if(loginForm.pword.value.length > maxLength)
{
strErrorMessage = "pasword must not more than 10 characters\n";
booValid=false;
}
if(loginForm.loginid.value.indexOf("@") == -1)
{
strErrorMessage = "please enter an e-mail address as your login name\n";
booValid=false;
}
if(!booValid)
{
alert(strErrorMessage);
}
return booValid;
}
我無法弄清楚什麼是這個代碼,它似乎並沒有在所有的javascript讀取。
我不知道爲什麼它沒有。我也試圖只使用登錄表單和JavaScript然後它的工作原理,當我把所有東西一起,然後它不起作用。
是的,我想是的,但我不能改變,因爲我已經在User455892上打勾了。 – James1 2010-09-27 05:26:14
我不介意,我知道阿曼多,他的概率也不在乎。不過,你應該能夠取消選中。要記住的重要一點是學習何時使用「名稱」,「班級」和「身份證」 – vol7ron 2010-09-27 15:48:12