Welcome Guest, Not a member yet? Register   Sign In
Form validation doesn't work with json variables
#1

[eluser]chzigkol[/eluser]
Hi to all,

I have a problem with the form validation process of Code Igniter.

I have a html form with some fields which I want to check for validation errors.

I use jQuery and JSON format to pass the values of these fields to my controller but the validation rules don't seem to work.

Is the JSON format the problem? I think that null values are passed to the validation process and that creates the failure.

What can I do? I want to keep the JSON format and use the internal validation process as well. Can I combine these two?

Thanks in advance.

Christos
#2

[eluser]pistolPete[/eluser]
Do you decode the JSON data anywhere in you controller?
Why do you want to use JSON instead of plain POST?
#3

[eluser]chzigkol[/eluser]
The truth is that I use the decode function after the validation check for a reason, but can this be the mistake that provokes the validation failure?

If I simply decode my json variable before the validation check, will my problem be solved? Well, I give it a try anyway.

I use json instead of POST cause I have more than ten variables + arrays to post to my controller and I want to keep them in a structure like json.




Theme © iAndrew 2016 - Forum software by © MyBB