title: javascript empty field form validation not working
body: <p>Hi I am new to javascript.</p>
  
  <p>I am trying to implement some javascript form validation
  I am trying to use the technique used here:
  <a href="http://www.w3schools.com/js/tryit.asp?filename=tryjs_form_validation" rel="nofollow">http://www.w3schools.com/js/tryit.asp?filename=tryjs_form_validation</a>
  to test for empty field in the form and using an alert to warn users
  But it is not work for me
  When i submit an empty form proceeds to the jsp file and the javascript does not catch the error</p>
  
  <p>here is my index.html file where the form is</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;head&gt;
      &lt;script&gt;
          function validateForm()
          {
              var stoneField=document.forms["bmiForm"]["stone"].value;
              var poundsField=document.forms["bmiForm"]["pounds"].value;
              var kgsField=document.forms["bmiForm"]["kgs"].value;
              var feetField=document.forms["bmiForm"]["feet"].value;
              var inchesField=document.forms["bmiForm"]["inches"].value;
  
              if ( stoneField = null || stoneField = "" &amp;&amp; poundsField = null || poundsField = "" &amp;&amp; kgsField = null || kgsField = "" &amp;&amp; feetField = null || feetField = "" &amp;&amp; inchesField = null || inchesField = "" )
              {
                alert("Please enter a weight and height");
                return false;
              }
              else
              {
  
               return true;
              } 
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;form name ="bmiForm" action="PrintBMI.jsp" onsubmit="return validateForm()" method=post  style="width:250px;"&gt;
      &lt;fieldset&gt;
      &lt;legend&gt;BMI Calculator&lt;/legend&gt;
      &lt;h3&gt;Enter your weight&lt;/h3&gt;
      Stone &lt;input type = text name = "stone" size = 1 maxlength = 2&gt;
      Pounds &lt;input type = text name = "pounds" size = 1 maxlength = 2&gt;
      &lt;br&gt;
      &lt;strong&gt;OR&lt;/strong&gt;
      &lt;br&gt;
      KGs &lt;input type = text name = "kgs" size = 1 maxlength = 3&gt;
  
      &lt;h3&gt;Enter your height&lt;/h3&gt;
      Feet &lt;input type = text name = "feet" size = 1 maxlength = 1&gt;
      Inches &lt;input type = text name = "inches" size = 1 maxlength = 2&gt;
      &lt;br&gt;
      &lt;strong&gt;OR&lt;/strong&gt;
      &lt;br&gt;
      Metres &lt;input type = text name = "metres" size = 1 maxlength = 4&gt;
      &lt;p&gt;&lt;input type=submit value = "Get BMI"&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;'
  </code></pre>
  
  <p>Does anyone see what I'm doing wrong. Thanks for your time.</p>