我得到一個SyntaxError:missing;在陳述之前。我不知道爲什麼我得到這個錯誤,因爲我的代碼與我正在使用的教科書完全相同。請幫忙。我會後的代碼和註釋,其中語法錯誤是:爲什麼我得到一個SyntaxError:失蹤;語句之前
<!DOCTYPE html>
<html lang="en">
<head>
<title> Practive</title>
<meta charset="utf-8">
<style>
input{display: block;
padding-bottom: 10px;
width: 250px;
text-align: left;}
label {float:left;}
</style>
<script type="text/javascript">
<!--
fuction validateForm() // SyntaxError: missing ; before statement
// before v
{
if (document.forms[0].userAge.value < 18){
alert ("Age is less than 18!");
return false;
} // end if
alert ("Age is valid.");
return true;
} // end function validateForm
// -->
</script>
</head>
<body>
<h1> JavaScript Form Handling </h1>
<form method="post" action="http://webdevfoundations.net/scripts/formdemo.asp" onsubmit="return validateForm();">
<label for="userName">Name: </label>
<input type="text" name="userName" id="userName">
<label for="userAge">Age:   </label>
<input type="text" name="userAge" id="userAge">
<input type="submit" value="send information" id="submit">
</form>
</body>
</html>
如果代碼是完全在教科書中,那麼教科書是錯誤的 – devnull69 2013-03-15 10:09:29