title: Validating form in jsp page
body: <p>I have a form with one input called 'name1', I 'd like to validate this input, making sure it has at least four characters. Here is my code.</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt; 
  
     function validateForm()
     {
      var x=document.forms["myForm"]["name1"].value;
      if (x==null || x=="")
      {
       alert("Name must be filled out");
        return false;
      }
     }
  </code></pre>
  
  <p></p>
  
  <pre><code>     &lt;form name="myForm" method="POST" action="write.jsp" onsubmit="return validateForm()" &gt;
        Name: &lt;input type="text" name="name1" value="&lt;%=name%&gt;" size="20"/&gt;  &lt;br&gt; 
        &lt;input type="submit" name="submit" onclick="window.close()"/&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p>This is not working, I think it's because this is a pop-up page and the alert from javascript couldn't pop-up again. Anyone could help me to solve this??</p>