title: Unable to Submit HTML form Validated With Javascript Class
body: <p>i'm new to programming especially JS i have an HTML FORM validated With JS CLASS the problem comes after fill out all required fields correctly but when i click the submit button i am getting the error message that prevent form from being submitted !</p>
  
  <p>since my code not work as it was intended what mistake i made there?</p>
  
  <p>how do i validate and submit a form using JS CLASS? (object oriented javascript)</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-html lang-html prettyprint-override"><code>&lt;html lang="en-US"&gt;
        &lt;head&gt;
         &lt;meta charset="utf-8"&gt;
          &lt;meta name="viewport" content="width=device-width,initial-scale=0.1,shrink-to-fit=no"&gt;
           &lt;link type="text/css" href="/css" rel="stylesheet"&gt;
            &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"&gt;
             &lt;title&gt;Javascript Form Validation&lt;/title&gt;
              &lt;style&gt;
               &lt;/style&gt;
                &lt;/head&gt;
                 &lt;body&gt;
                  &lt;div class="container"&gt;
                   &lt;div class="row justify-content-center"&gt;
                    &lt;div class="col-sm-6 col-md-6 col-lg-6"&gt;
                     &lt;div class="card"&gt;
                      &lt;div class="card-body"&gt;
  
      &lt;form method="post" name="myForm" id="myForm"&gt;
      &lt;div class="form-group"&gt;
      &lt;label for="exampleInputName1"&gt;Full name&lt;/label&gt;
      &lt;input type="text" class="form-control" name="name" id="exampleInputName1" aria-describedby="nameHelp" placeholder="Enter name"&gt;
      &lt;/div&gt; 
      &lt;button type="submit" name="login" class="btn btn-primary"&gt;Submit&lt;/button&gt;
      &lt;/form&gt;
      &lt;script&gt;
        class User
                  {
                      constructor(userName,submitButton)
                      {
                          this.userName = document.myForm.name.value;
                          this.submitButton = document.getElementById("myForm");
                      }
                      submitForm()
                      {
                          this.submitButton.onsubmit = function()
                          {
  
                          if(this.userName == "" || this.userName == null)
                          {
                             alert("Name Required");
                              return false;
                              }
                          }
                      }
                  }
                  let user = new User();
                  user.submitForm();
      &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>