I'm using the Prototype framework to send a form via Ajax, and I'm using a form validation script (http://tetlaw.id.au/view/javascript/...eld-validation) to validate the form. Both work beautifully by themselves. The problem is this: I need some way to merge the two so that the form submits after validation, and that the form is validated before it's submitted.
Here's the validation code:
var dancingForm = new Validation('formDance', {useTitles:true});
And the submission code:
document.observe('dom:loaded', function() {
function sendForm(event){
// we stop the default submit behaviour
Event.stop(event);
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);
});
I'm guessing I put the validation script somewhere in the sendForm() function, I just don't know where. Thanks.
Thanks