Hi,
I have a channel form that allows guests to adds entries to a channel (they post requests for content). The form submission is handled through jquery $(‘#formId’).ajaxForm() with json=”yes” on the form, and validation is set to inline in the form tag (error_handling=”inline”). However I can’t get form validation to work. If the form has no validation errors it submits correctly, but, if it contained validation errors then the user get a new page with the Json output.
The form looks like this:
{exp:channel:form channel="channelName" class="request" id="request" error_handling="inline" json="yes" rules:name="required|min_length[5]" rules:phone="required|min_length[5]|integer" rules:email="required|email"}
<ul>
<li>
<label for="name">{phrase:request_name}:</label>
<input name="name" id="name" type="text">
{error:name}
</li>
<li>
<label for="phone">{phrase:request_phone}:</label>
<input type="text" name="phone" id="phone">
{error:phone}
</li>
<li>
<label for="email">{phrase:request_email}:</label>
<input type="text" name="email" id="email">
{error:email}
</li>
</ul>
<input type="submit" value="{phrase:request_send}" id="submit">
{/exp:channel:form}
And the scripts that handles submission looks like this:
$('#request').ajaxForm({
dataType: 'json',
success: function(data) {
if (data.success)
$("#submit").addClass('success').attr('value', 'Request sent');
else
$("#submit").addClass('error').attr('value', 'Error');
});
Any ideas?
Thanks.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.