Steve, odd that I was just helping another poster named Fabien with this
yesterday. Here's the way:
$("#myform").submit(function() {
// do your extra form stuff here
var v = $(this).validate(validateOptionsHere);
if (v.form()) // runs form validation and returns true if
successful
this.submit(); // form will be submitted
else
alert('Error on form validation!')
return false;
});
----- Original Message -----
From: Steve Blades
To: [email protected]
Sent: Thursday, October 04, 2007 12:14 PM
Subject: [jQuery] Re: Validation madness
aaaaahhh, so the submit handler will run...when? I have some things I need to
do with some of these fields prior to the actual form submission.
On 10/4/07, Josh Nathanson <[EMAIL PROTECTED]> wrote:
Steve, you have an infinite loop, because your submitHandler is
re-submitting the form, which then calls the validate handler, which then runs
submitHandler and so on.
The validation plugin will automatically submit the form if no errors are
found, so you don't need to have a separate submitHandler function to submit
the form.
-- Josh
----- Original Message -----
From: Steve Blades
To: [email protected]
Sent: Thursday, October 04, 2007 11:59 AM
Subject: [jQuery] Validation madness
I'm using the validator plugin, and I have some code like this:
var errContainer = $('#CSForm div.error');
$('form#CSForm').validate({
errorContainer: errContainer,
errorLabelContainer: $("ol",errContainer),
rules: {
First_Name: "required",
Last_Name: "required",
EMail: {
required: true,
email: true
},
Make: "required",
Model: "required"
},
messages: {
First_Name: "Please enter your First Name",
Last_Name: "Please enter your Last Name",
EMail: "Please enter a valid email address",
Make: "Please select a make",
Model: "Please select a model"
},
wrapper: 'li',
submitHandler: rewriteMakeOption
})
....
function rewriteMakeOption(form){
// some other stuff
$(form).submit();
}
Trying to figure out what I'm doing wrong. I put some console logging
into place, only to see that the form was submitted 222 times before it was
stopped by Firefox (it killed IE completely). Anybody?
--
Steve "Cutter" Blades
Adobe Certified Professional
Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
http://blog.cutterscrossing.com
---------------
The Past is a Memory
The Future a Dream
But Today is a Gift
That's why they call it
The Present
--
Steve "Cutter" Blades
Adobe Certified Professional
Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
http://blog.cutterscrossing.com
---------------
The Past is a Memory
The Future a Dream
But Today is a Gift
That's why they call it
The Present