title: Html form validation with regex in javascript using getElementById?
body: <p>I want to validate an html form using regex for this example pattern: <strong>AAA.111#2222_aa-1234</strong> </p>
  
  <p>Currently my code is either returning "correct" for all input or "incorrect" for all input, and I cannot figure out where my issue is. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  var x = document.getElementById("myForm");
  
  function regExp(courseNum) {
    var vCourse = /([A-Z]{3})\.(\d{3})#(\d{4})_([a-z]{2})-(\d{4})/;
    return (vCourse.test(courseNum));
  }
  
  function isValid() {
      if (regExp(x)) {
        document.getElementById("demo").innerHTML = "Correct Format";
      } else {
        document.getElementById("demo").innerHTML = "Incorrect Format";
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h3&gt;Please enter your course number below&lt;/h3&gt;
  
  &lt;form id="myForm"&gt;
    Course: &lt;input type="text" name="course" id="course"&gt;&lt;br&gt;
  &lt;/form&gt;
  &lt;/br&gt;
    &lt;button onclick="isValid()"&gt;Validate&lt;/button&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script src="course.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'm in the middle of a javascript course and haven't covered many javascript concepts yet, so I'd like to use the knowledge we have covered up to this point. </p>
  
  <p>Any help with this is greatly appreciated!</p>