Validation question about email

Validation question about email

  1. <script type="text/javascript" src="includes/jquery-latest.js"></script>
    <script type="text/javascript" src="includes/validation.jquery.js"></script>
    <script>
      $(document).ready(function(){
        $("#emailForm").validate({
                    rules: {
                        firstname: "required",
                        lastname: "required",
                        email: "email"
                    },
                    errorElement: "span",
                    errorPlacement: function(error, element) {
                        error.insertAfter(element);
                    }
                });
      });
      </script>
















  1. <form action="address.php?action=doEmail" method="post" id="emailForm">
  2. <fieldset>
  3.   <ol>
  4.     <li>
  5.       <label for="firstname">First Name:</label>
  6.       <input type="text" name="firstname" id="firstname" size="55" class="colored-bg" />
  7.     </li>
  8.     <li>
  9.       <label for="lastname">Last Name:</label>
  10.       <input type="text" name="lastname" id="lastname" size="55" class="colored-bg" />
  11.     </li>
  12.     <li>
  13.       <label for="email">Email:</label>
  14.       <input type="text" id="email" name="email" size="55" class="colored-bg"/>
  15.     </li>
  16.     <li>
  17.       <label for="enquiry">Enquiry:</label>
  18.       <textarea name="enquiry" cols="42" rows="2" class="colored-bg" id="enquiry"></textarea>
  19.     </li>
  20.    </ol><br /><br />
  21. <input type="submit" class="button" value="SEND" />
  22. <!--  <a href="address.php" class="button">SEND</a> -->
  23. </fieldset>
  24. </form>

Here's my code which works fine (I've snipped out the irrelevant guff!).  At the moment, the validation for the email field is happening as soon as someone enters the first character - this is annoying.  Can it be made so that the email form validation happens at the same time as the other fields, ie onSubmit?

Thanks,
Ed