Validation question about email
- <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>
- <form action="address.php?action=doEmail" method="post" id="emailForm">
- <fieldset>
- <ol>
- <li>
- <label for="firstname">First Name:</label>
- <input type="text" name="firstname" id="firstname" size="55" class="colored-bg" />
- </li>
- <li>
- <label for="lastname">Last Name:</label>
- <input type="text" name="lastname" id="lastname" size="55" class="colored-bg" />
- </li>
- <li>
- <label for="email">Email:</label>
- <input type="text" id="email" name="email" size="55" class="colored-bg"/>
- </li>
- <li>
- <label for="enquiry">Enquiry:</label>
- <textarea name="enquiry" cols="42" rows="2" class="colored-bg" id="enquiry"></textarea>
- </li>
- </ol><br /><br />
- <input type="submit" class="button" value="SEND" />
- <!-- <a href="address.php" class="button">SEND</a> -->
- </fieldset>
- </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