[jQuery] validation plugin : Do something before validate
Hi list,
I'm using the jquery validation plugin (http://docs.jquery.com/Plugins/
Validation)
It works well.
Just I have a small problem. I use JCE editor (wysiwyg) and my page
gives the ability to switch from that editotr to a simple textarea.
JCE editor transmit the data just before submission and because the
validation is done before, I have to click twice before tha data are
submitted.
I tried to play with SubmitHandler, but in vain. Alerts are not
displaying.
Here comes the code :
$jq("#adminForm").validate(
{
submitHandler: function(form) {
alert('message :' + $jq("textarea#message").val() );
alert('hello');
alert( $jq (".mceContentBody").html() );
$jq("textarea#message").val($jq (".mceContentBody").html());
alert('message :' + $jq("textarea#message").val() );
return false;
form.submit();
},
rules: {
'subject': "required",
'message': {
required: true,
minLength: 10
}
},
messages: {
'subject': "Veuillez entrer un titre",
'message': {
required: "Veuillez renseigner le contenu.",
minLength: "Le contenu de votre billet doit faire au moins
{0} caractères."
}
}
});
THis code is correct, no?