title: Form submitting with empty required fields due to use of "placeholder="
body: <p>My form is tripping up with required fields are able to be submitted without entering anything in the field. I'd like to use placeholder text but it must be reading this as a value, hence the form goes through?</p>
  
  <p>I'm using the html 5 'placeholder' and 'required attributes. email address does get flagged as the placeholder text doesnt match the format i think.</p>
  
  <p>Is there any way to get the form to flag the other required fields?</p>
  
  <pre><code>&lt;form action="FormToEmail.php" method="POST" name="Competition"&gt;                                                                  
  &lt;div id="text"&gt;
  &lt;input class="field" value="" type="text" name="Name" required placeholder="FULL NAME*"&gt; 
  &lt;input class="field" value="" type="email" name="Email" required placeholder="EMAIL ADDRESS*"&gt;  
  &lt;input class="field" value="" type="text" name="Contact-number" required placeholder="CONTACT NUMBER*"&gt; 
  &lt;input class="field" value="" type="text" name="Code" required placeholder="UNIQUE CODE*"&gt; 
  
  &lt;p&gt;I have read the Terms and Conditions&lt;/p&gt;&lt;input type="checkbox" name="Terms and Conditions" value="Selected" required&gt;&lt;/div&gt;
  &lt;p &gt;Read the &lt;a href="competition-terms.html"&gt; Terms and Conditions&lt;/a&gt;.&lt;/p&gt;
  
  &lt;p&gt;* required field&lt;/p&gt;
  
  &lt;input class="btn btn-draw" type="submit" name="submit" value="Submit!" /&gt;  
  &lt;/form&gt;
  </code></pre>
  
  <p>EDIT: i recall now that i'm using the javascript below to show the placeholder text in older versions of internet explorer. This script does work for that with the knock on effect of the empty fields submitting. 
  I am probably best covered to leave it like this, but i'd be interested if there is any comprehensive solution to ensure placeholder text shows in older browsers and the empty fields are flagged.</p>
  
  <pre><code>$('[placeholder]').focus(function() {
  var input = $(this);
  if (input.val() == input.attr('placeholder')) {
  input.val('');
  input.removeClass('placeholder');
  }
  }).blur(function() {
  var input = $(this);
  if (input.val() == '' || input.val() == input.attr('placeholder')) {
  input.addClass('placeholder');
  input.val(input.attr('placeholder'));
  }
  }).blur().parents('form').submit(function() {
  $(this).find('[placeholder]').each(function() {
  var input = $(this);
  if (input.val() == input.attr('placeholder')) {
    input.val('');
  }
  })
  });
  </code></pre>