求大神指教这个代码为什么总是不成功?来自《Web编程入门经典--HTML、XHTML和CSS(第2版)》
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.
<html xmlns="http://www. lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-type" content="text/xhtml; charset=UTF-8" />
<title>Checking Text Fields</title>
<script type = "text/javascript">
function validate(form) {
var returnValue = true;
var formElements = form.elements;
for (var i=0; i<formElements.length; i++)
{
currentElement = formElements[i];
if (currentElement.value=="" && currentElement.className=="required") {
alert("The required field \""+currentElement.name +"\" is empty. Please provide a value for it.");
currentElement.focus();
returnValue = false;
break;
}
return returnValue;
}
}
</script>
</head>
<body>
<form name="frmEnquiry" method="post" action="register.aspx" onsubmit="return validate(this);">
<div class="label"><label for="Name">Name:</label></div>
<div class="formElement">
<input type="text" class="required" name="Name" size="12" id="Name" />
</div>
<div class="label"><label for="E-mail">E-mail:</label></div>
<div class="formElement">
<input type="text" class="required" name="E-mail" size="12" id="E-mail" />
</div>
<div class="label"><label for="txtEmail">Please enter your query here:</label></div>
<div class="formElement">
<textarea rows="8" class="required" cols="30" name="Query" id="Query">
</textarea>
</div>
<div class="label"><label for="txtEmail"> </label></div>
<div class="formElement">
<input type="submit" class="" value="Submit your query" />
</div>
</form>
</body>
</html>