I just tested this code on IE 6/7 and it does not work. I am using a thickbox ajax call to load this form into a lightbox. The forms loads just fine. If you don't fill anything out and submit the form, it will let it go through. It also seems to refresh the entire page which it shouldn't. Everything works fine on FF and Safari. Here is the code that is on the form page. Any idea why this might be happening?
$(document).ready(function() { $("#post_form").validate({ rules: { email: { required: true, email: true }, friends_email: { required: true, email: true } }, submitHandler: function(form) { var data = {} data.name = $(form).find('inp...@name=name]').val(); data.email = $(form).find('inp...@name=email]').val(); data.comments = $(form).find('inp...@name=comments]').val(); data.friends_name = $(form).find('inp...@name=friends_name]').val (); data.friends_email = $(form).find('textarea [...@name=friends_email]').val(); $.post("/user/emailfriend/{{ mls_listing_id }}/", data, function(responseData) { $("#fade").fadeOut("slow"); $("#done").html('<p class="bold">Thank you for your interest. Your friend will receive the e-mail shortly.</p>'); }, "json" ); } }); }); On Jan 25, 2:47 pm, issya <floridali...@gmail.com> wrote: > Thank you, that worked like a charm. > > On Jan 25, 2:22 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com> > wrote: > > > Try to move the code in your own submit handler to the > > submitHandler-callback: > > > $(document).ready(function() { > > $.validator.addMethod("phone", function(ph, element) { > > if (ph == null) { > > return false; > > } > > var stripped = ph.replace(/[\s()+-]|ext\.?/gi, ""); > > // 10 is the minimum number of numbers required > > return ((/\d{10,}/i).test(stripped)); > > }, "Please enter a valid phone number"); > > > $("#post_form").validate({ > > rules: { > > phone: { > > required: true, > > phone: true > > } > > }, > > submitHandler: function(form) { > > var data = {} > > data.name = $(form).find('inp...@name=name]').val(); > > data.email = > > $(form).find('inp...@name=email]').val(); > > data.phone = > > $(form).find('inp...@name=phone]').val(); > > data.comments = > > $(form).find('inp...@name=comments]').val(); > > > // suppose our django app called 'testapp' > > $.post("/user/scheduleshowing/T33432123/", > > data, > > function(responseData) { > > $("#fade").fadeOut("slow"); > > $("#done").html('<p class="bold">Thank you > > for your interest. > > An associate will contact you shortly.</p>'); > > }, > > "json" > > ); > > } > > }); > > > }); > > > Jörn > > > On Sun, Jan 25, 2009 at 6:46 PM,issya<floridali...@gmail.com> wrote: > > > > Hello, I am using a few plugins together for AJAX forms and > > > validation. I have validation on the name and phone fields. If you add > > > a class of required to the fields, the validation plugin will > > > automatically validate them. If you want to do more advanced > > > validation you have to tell it so. > > > > I have the below code and if I don't if I fill out the form but put > > > non integer values in the phone number field it will tell me to put a > > > valid number. But if I click on submit a second time it will let the > > > form post. Even though I did not fill in a valid phone number. What am > > > I doing wrong? > > > > $(document).ready(function() { > > > $.validator.addMethod("phone", function(ph, element) { > > > if (ph == null) { > > > return false; > > > } > > > var stripped = ph.replace(/[\s()+-]|ext\.?/gi, ""); > > > // 10 is the minimum number of numbers required > > > return ((/\d{10,}/i).test(stripped)); > > > }, "Please enter a valid phone number"); > > > > $("#post_form").validate({ > > > rules: { > > > phone: { > > > required: true, > > > phone: true > > > } > > > } > > > }); > > > $('#post_form').submit(function(event){ > > > event.preventDefault(); // cancel the default action > > > var form = this; > > > var data = {} > > > data.name = $(form).find('inp...@name=name]').val(); > > > data.email = > > > $(form).find('inp...@name=email]').val(); > > > data.phone = > > > $(form).find('inp...@name=phone]').val(); > > > data.comments = > > > $(form).find('inp...@name=comments]').val(); > > > > // suppose our django app called 'testapp' > > > $.post("/user/scheduleshowing/T33432123/", > > > data, > > > function(responseData) { > > > $("#fade").fadeOut("slow"); > > > $("#done").html('<p class="bold">Thank you for > > > your interest. > > > An associate will contact you shortly.</p>'); > > > }, > > > "json" > > > ); > > > }); > > > });