Javascript User-Input Validation
<p>I'm a javascript newbie. I am trying to create a web redirect to a client's development site based on a "Client ID" that they enter.</p>

<p>Here is what I have so far, you'll see I'm going about this completely backwards.</p>

<p>I would like a redirect to the URL in a new tab. BUT if they enter the wrong client ID, an alert pops up 'Sorry, try again.' With the alert added the way I have it, I get a pop-up regardless if they enter the correct 'code' or not.</p>

<pre><code>&lt;head&gt;
&lt;script&gt;

function validateCode()
{
var codeTextBox = document.getElementById("codeTextBox").value;

if (codeTextBox == 'C1')
{
    window.location.href = "http://www.client1.com";
} 
if (codeTextBox == 'C2')
{
    window.location.href = "http://www.client2.com";
} 
if (codeTextBox == 'C3')
{
    window.location.href = "http://www.client3.com";
} 
if (codeTextBox == 'C4')
{
    window.location.href = "http://www.client4.com";
}  else {
    alert('Sorry, try again.');
    }

}

&lt;/script&gt;
 &lt;/head&gt;

 &lt;body&gt;
 Enter User ID: 
 &lt;input type="text" name="codeTextBox" id="codeTextBox" /&gt;
 &lt;input type="submit" name="Submit" value="Submit" onclick="validateCode()" /&gt;
 &lt;/body&gt;
</code></pre>

<p>Be easy on me guys :) Thanks!</p>
