title: javascript not working properly on 2 forms in same html page
body: <p>even when the password has all the correct values !((password.match(passw)) is executing
  and if i remove the formvalidationlogin.js then also the formvalidationregistartion.js is throwing error for  f1 from. when the login and registartion were in seperate html pages these javascript functions worked perfectly.</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;title&gt;signup-login&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/index.css&quot;&gt;
  &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Jost:wght@500&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div class=&quot;main&quot;&gt;      
  &lt;input type=&quot;checkbox&quot; id=&quot;chk&quot; aria-hidden=&quot;true&quot;&gt;
  &lt;div class=&quot;signup&quot;&gt;
  &lt;form name=&quot;regform&quot; action=&quot;registrationsession.php&quot; onsubmit=&quot;return Validate()&quot; method=&quot;post&quot;&gt;
  &lt;label for=&quot;chk&quot; aria-hidden=&quot;true&quot;&gt;Sign up&lt;/label&gt;
  &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; placeholder=&quot;User name&quot; required=&quot;&quot;&gt;
  &lt;input type=&quot;email&quot; id=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Email&quot; required=&quot;&quot;&gt;
  &lt;input type=&quot;password&quot; id=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; required=&quot;&quot;&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;javascript/formvalidationregistration.js&quot;&gt;&lt;/script&gt;
  &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Sign Up&quot; class=&quot;login-button&quot;&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;div class=&quot;login&quot;&gt;
  &lt;form name=&quot;f1&quot; action=&quot;loginsession.php&quot; onsubmit=&quot;return Validate()&quot; method=&quot;post&quot;&gt;
  &lt;label for=&quot;chk&quot; aria-hidden=&quot;true&quot;&gt;Login&lt;/label&gt;
  &lt;input type=&quot;email&quot; name=&quot;email&quot; id=&quot;email&quot; placeholder=&quot;Email&quot; required=&quot;&quot;&gt;
  &lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; placeholder=&quot;Password&quot; required=&quot;&quot;&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;javascript/formvalidationlogin.js&quot;&gt;&lt;/script&gt;
  &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Login&quot; class=&quot;login-button&quot;&gt;  
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <pre><code>//formvalidationregistration.js
  
  function Validate() {
  
  var password = regform.password.value;
  
      var name = regform.username.value;
  
      var passw = &quot;^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&amp;*-]).{8,}$&quot;;
  
      if (!(password.match(passw))){
          alert(&quot;Password Should Contain At Least One Uppercase Letter, One Lowercase letter, One Number And One Special Character&quot;);
          return false;
      }
  
      else if(password.length &lt; 8) {
          alert(&quot;Password Must Be At least 8 Characters long&quot;);
          return false;
      }
  
      else if(name.length &lt; 6) {
          alert(&quot;Username Must Be At least 6 Characters long&quot;);
          return false;
      }
  
      else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(regform.email.value))) {
          alert(&quot;You have entered an invalid email address!&quot;);
          return false;
      }
  }
  </code></pre>
  <pre><code>//formvalidationlogin.js
  
  function Validate() {
  
      var password = f1.pass.value;
      
      var passw = &quot;^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&amp;*-]).{8,}$&quot;;
  
      if (!(password.match(passw))) {
          alert(&quot;Password Should Contain At Least One Uppercase Letter, One Lowercase letter, One Number And One Special Character&quot;);
          return false;
      }
  
      else if (password.length &lt; 8) {
          alert(&quot;Password Must Be At least 8 Characters long&quot;);
          return false;
      }
  }
  </code></pre>