I'm struggling a little with what I think should be a fairly basic problem so please be patient with me!
I'm just starting to pick up jQuery and am finding it a very useful tool in my web design belt but it's proving a little more tricky than I'd hoped. I'm building a fairly basic contact form that uses ASP to complete the send. I am hoping to use the jQuery validation plugin to perform some basic client-side validation to make sure that everyone enters at the very least a name, a valid email and a message. Once those things have been validated I then want the form to be sent using AJAX. I've got the basic code written but it seems to be ignoring the validation. I have attached the validation and sending section of my jQuery below. Can anyone see where I am going wrong? TIA
- //@Additions by EJS - jQuery + ASP email
- //AJAX Sending of ASP
- //+ Basic Validation
- function showRequest() {
- jQuery("#contactForm").validate({
- //set the rules for the field names
- rules: {
- name: {
- required: true,
- minlength: 2
- },
- mememail: {
- required: true,
- email: true
- },
- message: {
- required: true,
- minlength: 2
- }
- }
- });
- }
- function showResponse() {
- alert('Thanks for your comment squire!');
- disablePopup();
- }
- $(document).ready(function() {
- var options = {
- target: '#errormessage', // target element(s) to be updated with server response
- beforeSubmit: showRequest, // pre-submit callback
- success: showResponse // post-submit callback
- };
- // bind form using 'ajaxForm'
- $('form#contactform').ajaxForm(options);
- });