I have this form that validates the fields on submit through ajax (using Codeigniter’s Form_Validation Class).
<input type="text" name="field1" id="field1"> />
<span id="field1_error"></span>
....
<input type="text" name="field2" id="field2"> />
<span id="field2_error"></span>
...
<input type="text" name="field3" id="field3"> />
<span id="field3_error"></span>
<input type="submit" name="submit" id="btnPublish" />
On submit, jQuery calls CI’s validation method. Which would be the best way to output those validation errors with a single Ajax Call?
Maybe this approach can help you.. its more like a hint than complete solution…
On server side you will do validation and return JSON (for example)
– $progress is true/false – depending on validation result and $errors is array(name,translated_error/ or “”)
partial php:
partial jQuery: