title: JSP and JavaScript with form
body: <p>I have a form in a Registeration.jsp page:</p>
  
  <blockquote>
    <p>form name="users" method="post" onSubmit="return checkCorrect()"
    action="Registeration.jsp"></p>
  </blockquote>
  
  <p>The Script checkCorrect is written at the start of the page, returns true or false based on information submitted to the form (using getElementById if it matters) and the script definitely works (worked on html page without jsp before)</p>
  
  <p>after the form I have this:</p>
  
  <blockquote>
    <p>&lt;% if(request.getMethod().equals("POST")){...}</p>
  </blockquote>
  
  <p>And I need that the jsp part will work ONLY if and after the form is successfully submitted, but somehow the javascript script is not called and don't work and the form is always submitted. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>edits:<br>
  there's no redirection in my page, the javascript check function, the form, and the JSP part that procces the form after submitting it are at the same page.<br>
  the jsp part is used to send the data from the form to a database.<br>
  the function:</p>
  
  <blockquote>
    <p>function checkCorrect(){<br>
    var fullname=document.getElementById("fullname").value;<br>
    ...<br>
    if (response.length==0)<br>
         {<br>
           return true;<br>
         }<br>
         else<br>
         {<br>
           alert ("These problems are found in your form:\n\n"+response);<br>
           return false;<br>
         }<br>
    }    </p>
  </blockquote>
  
  <p>then come the <code>body</code> and the form and then<br>
  the jsp part:  </p>
  
  <blockquote>
    <p>&lt;%  </p>
    
    <p>if(request.getMethod().equals("POST")){        </p>
    
    <p>String fullname=request.getParameter("fullname");<br>
    and go on.. } % ></p>
  </blockquote>
  
  <p>Solution:<br>
  check the JavaScript part really good people it doesn't have compiler so even a tiny problem there can screw up the entire project.</p>