Javascript document.reg_页面未定义

Javascript document.reg_页面未定义,javascript,Javascript,为什么这些是未定义的?它们包含在表单验证js文件中: var student\u name=document.reg\u page.student\u name.value; var course\u id=document.reg\u page.course\u id.value 当我有这张表格的时候 <div id="container"> <div id="page"> <form name="reg_page" action="thanks.htm"

为什么这些是未定义的?它们包含在表单验证js文件中:

var student\u name=document.reg\u page.student\u name.value; var course\u id=document.reg\u page.course\u 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>

网上登记表格
学生姓名:
课程编号:
选择您学习过的编程语言:
JavaScript
python
ASP.NET
PHP
预期毕业年份:
2011
2012
2013
2014

您是否在加载页面其余部分之前进行这些声明


例如,如果在正文上方包含脚本,并且声明不在函数中,它将查找浏览器尚未创建的表单和输入元素。

将尝试将它们添加到表单验证函数本身。