title: How to validate form(using javascript) and run a function if form is valid?
body: <p><code>&lt;form onsubmit="myfunction()"&gt;//sign up content&lt;/form&gt;</code></p>
  
  <pre><code>function myfunction() {
                  document.getElementById('signUpContent').style.display = "none";
                  document.getElementById('MessageToBeDisplayed').style.display = "block";
              }
  </code></pre>
  
  <p>I'm making a website sign up page and in that when i click the submit  button,i have set it to validate my form but I am unable to use both form validation and <code>onclick</code>.If the user's input is correct then it should perform the <code>onclick</code> function.</p>
  
  <p>i have tried adding <code>onclick</code>and <code>onsubmit</code> events to both button and form tags but it doesnt work</p>