Do Javascript functions need to be stored in their own file to be called?
<p>The situation was as follows:</p>

<p>I had this form in a .php file:</p>

<pre><code>&lt;form action="/flash_card/scripts/create_user_gate.php"
            onsubmit="return validateForm()" method="post"&gt;
            &lt;table align="center"&gt;
                &lt;tr&gt;
                    &lt;td&gt;Name&lt;/td&gt;
                    &lt;td&gt;&lt;input type="text" name="name" id="uname"
                        onkeydown="return checkInput(event)"&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;Password&lt;/td&gt;
                    &lt;td&gt;&lt;input type="password" name="password"&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;button onclick="return validateForm()" type="button"
                            title="Create user!" name="submit"&gt;Create!&lt;/button&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/form&gt;
</code></pre>

<p>With this just outside the body tag:</p>

<pre><code>&lt;script type="text/javascript" src="/flash_card/js/webscripts.js"&gt;&lt;/script&gt;
</code></pre>

<p>This file contained:</p>

<pre><code>/**
 * 
 */

function validateForm(){
    document.write("BURNED INTO YOUR MINDDDD");
    return false;
}

function onlyAlphaNumericAndModifiers(e) {
    var keynum;
    var keychar;
    var numcheck;

    if (window.event) // IE
    {
        keynum = e.keyCode;
    } else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    // letters, numbers, backspace, delete, arrow keys
    if (keynum &gt;= 65 &amp;&amp; keynum &lt;= 90 || keynum &gt;= 48 &amp;&amp; keynum &lt;= 57
            || keynum == 8 || keynum &gt;= 37 &amp;&amp; keynum &lt;= 40 || keynum == 46) {
        return true;
    } else {
        return false;
    }
}
</code></pre>

<p>After fiddling around, I find that I cannot get my validateForm() to fire at all, so I separate it into its own file and suddenly on the click fires validateForm() properly and the text box's onkeydown is firing checkInput correctly as well.</p>

<p>Where did I go wrong? I am assuming that a .js file can contain more than one function, so I must be missing something fundamental.</p>
