self.location.href with validation
<p>I really could do with some help with a form redirection and validation issue for my website. </p>

<p>I’ve been successful in getting the input “password” to redirect to the input value, however if users get the password wrong they get a 404 error - which is correct, but not great for the user.</p>

<p>My question is, is there anyway of having the form validated against a txt or xml file on the server with a list of passwords to validate against before submit??  So the user gets an alert if incorrect rather than 404!</p>

<p>Below is a sample of what currently works, your help is appreciated!!</p>

<pre><code>&lt;html&gt;&lt;head&gt;
&lt;SCRIPT TYPE="text/javascript"&gt;

function login() {
   if (validLogin()) {
      password = document.userInfos.password.value;
      self.location.href=
        ""+password+"";
      }
   }
function validLogin() {
   if (isBlank(document.userInfos.password.value)){
      alert("Can't be blank");
      document.userInfos.password.focus();
      return false;
      }
   return true;      
   }
function isBlank(s) {
   return (s == "");
   }

   function doKey(e) {
//check to see if the return key was pressed ...
if( event.keyCode == 13){ 
//call the login function ...
login();
//prevent the page from reloading ...
return false;
}
}

//listen for keypress events and then call doKey()
document.onkeypress = doKey;

&lt;/SCRIPT&gt;

&lt;/head&gt;

        &lt;form  NAME="userInfos" &gt;


&lt;INPUT TYPE="password" NAME="password" LENGTH="20" style="color: #333333" size="23" &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;INPUT TYPE="button" style="color: #333333" onClick="login()" VALUE=" View "&gt;
&lt;/form&gt;

    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
