[eluser]tastebuds[/eluser]
[quote author="CroNiX" date="1334855196"]The only built in way is using validation_errors(), as dhiya pointed out. However, this will return a string containing all error messages. If you would like an array that contain the field names along with the error messages for each field, you would have to extend the validation library and create a new method that returns $_error_array.[/quote]
I extend the library as just u pointed out and here's the code..
Code:
class MY_Form_validation extends CI_Form_validation{
var $_error_array = array();
function __construct($config=array()){
parent::__construct($config);
}
function error_array(){
if(count($this->_error_array)===0){
return FALSE;
}else{
return $this->_error_array;
}
}
function get_tae(){
return "TAE!";
}
}
and i echo'ed out the errors in json format in php validation and i get this
This is the desirable output
{"username":"The username field is required.","email":"The email field is required."}
but when i try in jquery ajax it just returning
false, here's the snippet for the jquery code btw
Code:
$(function(){
$('#my_form').submit(function(e){
$.get('ajax_verify', function(data){
console.log(data);
})
e.preventDefault();
})
});
i dont know if im doing it wrong and i am very very sorry for the noobish question, need help please >.<