I'm using the jQuery Form plugin (http://malsup.com/jquery/form/) to return an AJAX message on successful submission of a contact form. However, I also need to do AJAX validation.
My current form and script looks like this;
<div id="send1">
{exp:freeform:form
form_name="callback"
form:id="callback"
return="ajax/success_callback"
required="full_name|message"
}
<label>Full Name</label>
{if freeform:error:full_name}
{freeform:field:full_name}
<label>Message</label>
{if freeform:error:message}
{freeform:field:message}
<input class="more_info" type="submit">
{/exp:freeform:form}
</div>
<div id="send2"></div>
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/jquery.form.min.js"></script>
<script>
// prepare the form when the DOM is ready
$(document).ready(function() {
// bind form using ajaxForm
$('#callback').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#send2',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#send1').hide();
$('#send2').fadeIn('slow');
}
});
});
</script>
As you can see, on success I am hiding the 'send1' div and simply loading a success template into the 'send2' div.
I was wondering if anyone might be able to help on how to construct the error messaging using AJAX that will work using or alongside the jQuery Form plugin?
Thank you.