为什么这些未定义?它们包含在表单验证 js 文件中:
var student_name = document.reg_page.student_name.value; var course_id = document.reg_page.course_id.value;
当我有这个表格
<div id="container">
<div id="page">
<form name="reg_page" action="thanks.htm" onsubmit = "return form_validation()" method="post">
<table id="form">
<tr>
<td colspan="2"><div id="table_title">Web Registration Form</td>
</tr>
<tr>
<td class="label">Student Name:</td><td><input name="student_name" id="s" size="15" value="name"/></td>
</tr>
<tr>
<td class="label">Course ID:</td><td><input name="course_id" id="c" size="10" /></td>
</tr>
<tr>
<td class="label">Select the programming languages you have studied:</td>
<td>
<div><input type="checkbox" name="js" id="y" value="JS" />JavaScript</div>
<div><input type="checkbox" name="py" id="y" value="Python" />Python</div>
<div><input type="checkbox" name="asp" id="y" value="ASP.NET" />ASP.NET</div>
<div><input type="checkbox" name="php" id="y" value="PHP" />PHP</div>
</td>
</tr>
<tr>
<td class="label">Expected Year of Graduation:</td>
<td>
<div><input type="radio" name="year" id="y" value="2011" />2011</div>
<div><input type="radio" name="year" id="y" value="2012" />2012</div>
<div><input type="radio" name="year" id="y" value="2013" />2013</div>
<div><input type="radio" name="year" id="y" value="2014" />2014</div>
</td>
</tr>
<tr>
<td colspan="2" id="buttons">
<input type="submit" name="sub" value="Log In" id="s" /> <input type="reset" name="re" value="Clear Form" id="r" />
</td>
</tr>
</table>
</form>
</div>