title: Simple javascript form validation won't return true
body: <p>I created this function where it checks for multiple textboxes if they have values onsubmit. Basically it is a javascript form validator. When there are empty textboxes, form shouldn't submit and alert the user that there are required fields. Now, this works for me perfectly, however, when there are values already and the form is submitted, it still doesn't submit even though it should. I created an if statement to check if the errorString is empty or null, if it is, the form should submit but what happens is that it alerts the user with a blank string. I think the code is still going inside the if(errorString!=null || errorString=="") statement even though it shouldn't.</p>
  
  <p>Thanks in advance</p>
  
  <p>Please see my code below:</p>
  
  <pre><code>            function validateForm()
          {
              var txtTitle = document.forms["actionStepsForm"]["txtTitle"].value;
      var txtRequestor = document.forms["actionStepsForm"]["txtRequestor"].value;
              var txtReprocessingRequest = document.forms["actionStepsForm"]["txtReprocessingRequest"].value;
  
              document.getElementById('rowCount').value = counter-1;
  
      var errorString = "";
  
              if (txtTitle==null || txtTitle=="")
              {
                  errorString += "Title field is required. \n";
              }
              if (txtRequestor==null || txtRequestor=="")
              {
                  errorString += "Requestor field is required. \n";
              }
              if (txtReprocessingRequest==null || txtReprocessingRequest=="")
              {
                  errorString += "Reprocessing request FR is required. \n";
              }
  
  
              if (errorString!=null || errorString!="")
              {
                  alert(errorString);
                  return false;
              }
              else
              {
                  return true;
              }
  
          }
  
  //implementation if HTML form
  &lt;form name="actionStepsForm" id="actionStepsForm" action="add_reprocessing.php?action=add" method="POST" onsubmit="return validateForm()"&gt;
  </code></pre>