title: Double Alert Windows
body: <p>I am getting double Alert prompts for a single form: The alert pops up the first time, then when I click OK, the same one pops open again. I think my code should do the alert once when it hits "else  window.alert(sameWarning) and the stop when it reaches "return false()"; but it seems return false() is causing the alert twice. Maybe because I have two forms on one page; yet, they have two separate function names ("signinForm()" and "saveSignUp()")and call two separate forms (forms[0] and forms[1])?  I think my code is correct, but I can't figure it out at this point. Any help would be appreciated. Thanks in advance!</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //FIRST FUNCTION FOR FORMS[0]
  function signinForm(){
  
          // var sameWarning = "The required fields were not submitted for the following error(s).  \n \n";
          var warningLogin = "The following field(s) require an entry: \n \n";
          var sameWarning = warningLogin;
  
          var userName = document.forms[0].userName.value;
          var pswd = document.forms[0].pswd.value;
  
          if(userName == ""){ 
          sameWarning += " - First Name \n";
          }
  
          if(pswd == ""){ 
          sameWarning += " - Password \n";
          }
  
          if (warningLogin == sameWarning){ 
              return true; 
              }
  
          else  { 
              window.alert(sameWarning);  
          }
      return false;   
     }
  
  //SECOND FUNCTION CALL FOR FORMS[1] 
  function saveSignUp(){
  
          // var warning = "The required fields were not submitted for the following error(s).  \n \n";
          var warning = "The following field(s) require an entry: \n \n";
          var same = warning;
  
          var firstName = document.forms[1].firstName.value;
          var lastName = document.forms[1].lastName.value;
          var email = document.forms[1].email.value;
          var phone = document.forms[1].phoneNumber.value;
  
          if(firstName == ""){ 
          //firstName.style.backgroundColor="red";
          warning += " - First Name \n";
          }
  
          if(lastName == ""){ 
          warning += " - Last Name \n";
          }
  
          if(email == ""){ 
          warning += " - Email \n";
          }
  
          if(phone == ""){ 
          warning += " - Work Phone \n";
          }
  
          if(phone &lt; 5 ){
              warning += " - Must be a numberssss \n";
              }
  
          if (warning == same){
              return true; 
          } 
  
          else  { 
              alert(warning);         
          }
      return false;
     }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;h1&gt;Login&lt;/h1&gt;
  &lt;form method="post" onsubmit="return signinForm();" action="" &gt;
      &lt;input type="text" placeholder="Username/Email" name="userName"&gt;
      &lt;input type="password" placeholder="Password" name="pswd" id="pswd"&gt;
      &lt;input type="submit" onclick="signinForm();" value="Sign In"&gt;
  &lt;/form&gt;
  &lt;h1&gt;Sign Up!&lt;/h1&gt;
      &lt;form method="post" onsubmit="return saveSignUp()" action="" &gt;
      &lt;input type="text" placeholder="First Name" name="firstName"&gt;
      &lt;input type="text" placeholder="Last Name" name="lastName"&gt;
      &lt;input type="text" placeholder="Email" name="email"&gt;
      &lt;input type="text" placeholder="Phone Number" name="phoneNumber"&gt;
      &lt;input type="submit" onclick="saveSignUp();" class="button wide" value="Request an Account"&gt;        
  </code></pre>
  
  <p></p>