Form submits even if validation fails
<p>I'm just learning Javascript, so bear with me if my question seems silly...</p>

<p>I need to create an html form and run some validation on the fields. Regardless of whether the fields are correctly filled or not, I get an error 404 when hitting the submit button. If I copy/paste someone else's code that does the same thing, it works fine. The file "somepage.php" does not exist, but neither does it for the other person's code.</p>

<p>I coded it in CodeLobster, then in Notepad++. No change.</p>

<p>Here's the HTML file, and further down is the content of the javascript file...</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;html&gt;

    &lt;head&gt;
        &lt;title&gt;Registration Form&lt;/title&gt;
        &lt;script type="text/javascript" src="js.js"&gt;&lt;/script&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;form action="somepage.php" onsubmit="checkLogin()" method="post" &gt;

                Name: &lt;input type="text" name="name" id="nameF" /&gt;&lt;br /&gt;
                Email: &lt;input type="text" name="email" id="emailF" /&gt;&lt;br /&gt;

            &lt;input type="submit" value="Submit" name="submit" /&gt;    

        &lt;/form&gt;
    &lt;/body&gt;

&lt;/html&gt;

function checkLogin()
{
   var emailPattern = /^\w+([\.\-]?\w+)*@\w+([\.\-]?\w+)*\.[a-z]{2,6}$/i;
   var email = document.getElementById('emailF').value;
   var name = document.getElementById('name').value;    

    if (email == "")
    {
        alert("Please enter valid email address.");
       document.getElementById('emailF').select();
        document.getElementById('emailF').focus();
       return false;
    } else if   (name == "") {
        alert("Please enter your name.");
       document.getElementById('nameF').select();
        document.getElementById('nameF').focus();
       return false;
    }  else if (!emailPattern.test(email)) {
        alert("The email address entered is invalid");
       document.getElementById('emailF').select();
        document.getElementById('emailF').focus();
       return false;
    }
    return true;    
}
</code></pre>
