title: password validation not matching, clearing all the fields.
body: <p>I have a form validation script all the validation work. but the fields clear up when the alert about the passwords not matching shows up? how can i avoid that?     </p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
  
   function formValidator(){
  // Make quick references to our fields
  var FNAME = document.getElementById('FNAME');
  var LNAME = document.getElementById('LNAME');
  var EMAIL = document.getElementById('EMAIL');
  var GENDER = document.getElementById('GENDER');
  var ADDRESS = document.getElementById('ADDRESS');
  var CONTACTNO = document.getElementById('CONTACTNO');
  var PASSWORD = document.getElementById('PASSWORD');
  var PASSWORD2 = document.getElementById('PASSWORD2');
  
  // Check each input in the order that it appears in the form!
  if(isAlphabet(FNAME, "Please enter only letters for your first name"))
  {
      if(isAlphabet(LNAME, "Please enter only letters for last name"))
      {
          if(emailValidator(EMAIL, "Please enter a valid email address"))
          {
              if(madeSelection(GENDER, "Please Choose a Gender"))
              {
                  if(isAlphanumeric(ADDRESS, "Numbers and Letters Only for Address"))
                  {
                      if(isNumeric(CONTACTNO, "Please enter only numbers for Contact No."))
                      {
                          if(lengthRestriction(PASSWORD, 6))
                          {
                              if (PASSWORD2 != PASSWORD)
                              {
                              alert ("You did not enter the same new password twice. Please re-enter your password.");
                              return true;
                              }   
                          }
                      }
                  }
              }
          }
      }
  }
  
  return false;
  
   }
  </code></pre>
  
  <p>i think that there is no problem with my other functions? </p>
  
  <pre><code> function notEmpty(elem, helperMsg){
  if(elem.value.length == 0){
      alert(helperMsg);
      elem.focus(); // set the focus to this input
      return false;
  }
  return true;
   }
  
   function isNumeric(elem, helperMsg){
  var numericExpression = /^[0-9]+$/;
  if(elem.value.match(numericExpression)){
      return true;
  }else{
      alert(helperMsg);
      elem.focus();
      return false;
  }
   }
  
  function isAlphabet(elem, helperMsg){
  var alphaExp = /^[a-zA-Z]+$/;
  if(elem.value.match(alphaExp)){
      return true;
  }else{
      alert(helperMsg);
      elem.focus();
      return false;
  }
   }
  
   function isAlphanumeric(elem, helperMsg){
  var alphaExp = /^[0-9a-zA-Z]+$/;
  if(elem.value.match(alphaExp)){
      return true;
  }else{
      alert(helperMsg);
      elem.focus();
      return false;
  }
   }
  
   function lengthRestriction(elem, min){
  var uInput = elem.value;
  if(uInput.length &gt;= min){
      return true;
  }else{
      alert("Please enter atleast " +min+ " characters");
      elem.focus();
      return false;
  }
  }
  
  function madeSelection(elem, helperMsg){
  if(elem.value == "Please Choose"){
      alert(helperMsg);
      elem.focus();
      return false;
  }else{
      return true;
  }
   }
  
  function emailValidator(elem, helperMsg){
  var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
  if(elem.value.match(emailExp)){
      return true;
  }else{
      alert(helperMsg);
      elem.focus();
      return false;
  }
   }
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>i guess that i'm doing this part wrong?? but i don't know how to fix it? please help.</p>
  
  <pre><code>if (PASSWORD2 != PASSWORD)
  {
  alert ("You did not enter the same new password twice. Please re-enter your password.");
  return true;
  }   
  </code></pre>