title: Run Javascript function before calling Servlet
body: <p>I am learning <strong>Java Servlets</strong> and I am working on a simple homework assignment. I have an <strong>html</strong> page containing a <code>form</code>, that is submitted to a <strong>servlet</strong>, does some processing, and uses a <code>printwriter</code> to render an html page with results. </p>
  
  <p>Now, I want to add <strong>Javascript</strong>, which I am familiar with. Is there a way that I can write a Javascript function to validate data in the form, and if the data is valid, then call the servlet, otherwise, don't call the servlet?</p>