Sorry, missed the link to the docs in the first post. According to them, you can do:
Code:
document.observe('dom:loaded', function() {
function sendForm(event){
// we stop the default submit behaviour
Event.stop(event);
var dancingForm = new Validation('formDance', {useTitles:true});
if(!dancingForm.validate()){
return;
}
var oOptions = {
method: "POST",
parameters: Form.serialize("formDance"),
asynchronous: true,
onFailure: function (oXHR) {
$('show_hide_form').update('<fieldset class="no_me"><legend>fail</legend><p>Your message was not sent successfully. Please <a href="index.php?dance2the=contact">try again</a>.</p></fieldset>')
},
onSuccess: function(oXHR) {
$('ctitleholler').update('you sent me a holler.');
$('cinfo').update();
$('show_hide_form').update(oXHR.responseText);
}
};
var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "forms.php", oOptions);
}
Event.observe('formSubmit', 'click', sendForm, false);
});
Just to be on the safe side (zooming in and adding):
Code:
var dancingForm = new Validation('formDance', {useTitles:true, onSubmit:false});
if(!dancingForm.validate()){
return;
}
The dancingForm.validate() is said to return the boolean value I was looking for. Adding the , onSubmit:false is said to prevent the Validation function from messing with whether the form submits or not, which presumably you already have covered, so don't want the Validation function re-enabling it unexpectedly.
Bookmarks