title: Validation form using Javascript, seem to be missing a little code or perhaps a little understanding
body: <p>So here's what I have so far.  What I'd like my code to render is that if any of the three user inputs are invalid, the corresponding error message should be displayed on screen.  </p>
  
  <p>As it is at the moment, this does not happen....also what I thought would be a nice touch is that once the correct input has been typed, that it would then display a green tick mark after the input field, alas I have been unable to implement this.    </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
      &lt;html&gt;
  
      &lt;head&gt;
  
          &lt;title&gt;Validation&lt;/title&gt;
  
          &lt;script type="text/javascript"&gt;
              &lt;!--
  
              function validate_form() {
                  valid = true;
  
                  if (document.contact_form.pin.value == "") {
                      alert("Please fill in your '4 Digit PIN' in the box.");
                      valid = false;
                  } else if (document.contact_form.pin.value == "1234") {
                      content: "✓";
                      color: green;
                  }
  
                  if (document.contact_form.surname.value == "") {
                      alert("Please complete your surname");
                      valid = false;
                  } else if (document.contact_form.surname.value == "Doe") {
                      content: "✓";
                      color: green;
                  }
  
                  if (document.contact_form.email.value == "") {
                      alert("Icorrect email address for current user");
                      valid = false;
                  } else if (document.contact_form.email.value == "doe09@gmail.com") {
                      content: "✓";
                      color: green;
                  }
  
  
  
  
                  return valid;
              }
  
              //--&gt;
          &lt;/script&gt;
  
      &lt;/head&gt;
  
      &lt;body bgcolor="#FFFFFF"&gt;
  
          &lt;form name="contact_form" method="post" action="http://www.dcu.ie/" onSubmit="return validate_form ( );"&gt;
  
              &lt;h1&gt;John Doe (C1_A2_2015)&lt;/h1&gt;
              &lt;p&gt;4 Digit PIN:
                  &lt;input type="text" name="pin"&gt;
              &lt;/p&gt;
              &lt;p&gt;Surname:
                  &lt;input type="text" name="surname"&gt;
                  &lt;p&gt;E-mail:
                      &lt;input type="text" name="email"&gt;
  
  
  
                      &lt;p&gt;
                          &lt;input type="submit" name="send" value="Validate Inputs"&gt;
                      &lt;/p&gt;
  
          &lt;/form&gt;
  
      &lt;/body&gt;
  
      &lt;/html&gt;
  </code></pre>