title: Uncaught TypeError: Cannot read property 'reset' of null in Javascript
body: <p>I am trying to validate email in a form input by a button click.
  Here is the code:</p>
  
  <pre><code>function ValidateEmail(inputText) {
    var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    if (inputText.value.match(mailformat)) {
      document.form1.coemail.focus();
      return true;
    } else {
      alert('You have entered an invalid email address!Enter again');
      document.getElementById('form1').reset();
      return false;
    }
  }
  
  &lt;button class="btn btn-primary nextBtn btn-lg pull-right" type="button"onClick="ValidateEmail(document.form1.coemail)"&gt;Next&lt;/button&gt;
  </code></pre>
  
  <p>On clicking the Next button I get an alert message correctly but after that it redirects to next page instead of resetting the current one.
  On inspecting element in chrome's console,I found this error:
  <strong>Uncaught TypeError: Cannot read property 'reset' of null</strong> </p>
  
  <p>Where am I wrong here ?</p>