![]() |
JQuey & Form Validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: JQuey & Form Validation (/showthread.php?tid=38685) |
JQuey & Form Validation - El Forum - 02-15-2011 [eluser]jstine[/eluser] Hi all, So, I'm having a problem retrieving CI error messages to my form that I'm posting via JQuery Ajax. Basically, I use a JQuery Ajax post to post the data to my function. I then run the validation and if it returns false I try to echo the errors with Code: echo validation_errors(); In my ajax function I have the success set to take the response and present it to the user via a alert box, but even when there are errors the alert box just pops up with no error information. If I change my "echo validation_errors();" to "echo "hello";" the alert displays the "hello" as expected when there are errors. Does anyone have any ideas why echo validation_errors(); doesn't work here and what I can do to fix it? I've been pulling my hair out! Thanks in advance. JQuey & Form Validation - El Forum - 02-15-2011 [eluser]Twisted1919[/eluser] You need to return the errors from within your controller, not echo them in php view file. so you will have something like: Code: //PHP class method JQuey & Form Validation - El Forum - 02-16-2011 [eluser]jstine[/eluser] Thanks for the reply. For some reason I still can't get it to work. Here's my controller code: Code: $this->form_validation->set_rules('su_first_name', 'First Name', 'trim|required'); And my view's js: Code: var user_first = $("input#su_first_name").val(); Any ideas why it's still not working are appreciated! JQuey & Form Validation - El Forum - 02-16-2011 [eluser]Twisted1919[/eluser] Using firebug, can you see the result of the request ? (if you don't have firebug, install it, it will help you allot, it is a firefox extension that should't miss to any developer) Also, can you post the full JS code for form submission ? JQuey & Form Validation - El Forum - 02-18-2011 [eluser]jstine[/eluser] Thanks for helping with this. Using firebug the response I get from the post is as follows: {"result":"error","msg":""} It looks like no error message is being generated. My javascript looks like this: Code: function createAccount() |