title: HTML Form with Javascript Validation & Alert
body: <p>I'm working on a class project and I am wondering if anyone can provide some input/info as to how I would go about to validating my form fields in a better way. Specifically, I want the alert box to pop up to show all of the missing required fields instead of one box per missing field. Any input would be swell.</p>
  
  <pre><code>&lt;script type="text/Javascript"&gt;
  function validateForm(assignmentForm)   
  {
      valid = true
      if (document.assignmentForm.firstName.value=="")
      {
          alert ("Please fill in your first name.");
          valid = false;
      }
      if (document.assignmentForm.lastName.value=="")
      {
          alert ("Please fill in your last name.");
          valid = false;
      }
      return valid;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm new to using javascript within HTML so I apologize in advance for what is most likely a very newbie question. Also, here's a snippet of the HTML portion:</p>
  
  <pre><code>&lt;!--Name Text Fields--&gt;
   &lt;form id="assignmentForm" name="assignmentForm" method="post" onsubmit="return validateForm();"&gt;
    &lt;table cellspacing="15"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;a href="#"&gt;First Name: &lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" id="firstName" name="firstName"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;a href="#"&gt;Last Name: &lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" id="lastName" name="lastName"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>