Hi there, i’m building my first form with Safecracker which will display the success or failure message above the form without the need for redirecting to another page.
When I click on the submit button without entering any data I get the following message “Failed with the following errors:”, but I don’t see the details of the fields that were in error. I was wondering if someone might be able to help me resolve this?
I have this code place in the head of the page:
[removed]
jQuery(document).ready(function($){
$('#faq').ajaxForm({
dataType: 'json',
success: function(data) {
if (data.success) {
$('#success').html('You successfully added a new entry with entry_id ' + data.entry_id).fadeIn();
} else {
$('#failed').html('Failed with the following errors: '+data.errors.join(', ')).slideDown();
}
}
});
});
[removed]This is the code I have in the body of the page:
{exp:safecracker channel="ask_a_question" return="safecracker/ENTRY_ID/" rules:cf_ask_a_question_name="required" rules:cf_ask_a_question_email="valid_email" rules:cf_ask_a_question_question="required" id="faq" json="yes"}
<fieldset>
<ul>
<div id="success"></div>
<div id="failed">{if error}{error}{/if}</div>
{custom_fields}
<li>{if text}<label for="{field_name}">{field_label}</label><input type="text" id="{field_name}" name="{field_name}" value="{field_data}" />{if required} *{/if}{/if}</li>
<li>{if textarea}<label for="{field_name}">{field_label}</label><textarea id="{field_name}" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea>{if required} *{/if}{/if}</li>
{/custom_fields}
<li class="form-button"><input class="submit rounded" type="submit" value="Send"/></li>
</ul>
</fieldset>
{/exp:safecracker}Thank you.