• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation of Data / AJAX


Sorry my english is not quite good. I am new to CI and its realy a great piece of code.

I have an Form with several Input Boxes. The user can type in Title, Text etc. with onBlur an Ajax-Request is activated and the Value of the Input Boxes is send to an Ajax File.

Works fine so far. My Problem is now, that I want to validate the incomming data: Right size? Only Alpha_numeric?

Is there any function I can use for? Perhaps like: $this->string->validate($rules,$string) ?

I've looked @ the Wiki and User Guide, but found nothing.


I assume you are referring to what you would use to validate on the server while processing an ajax request ...

If this is the case, you missed the reference in the User Guide: userGuide->formValidation->ruleReference

You'll notice just below the table it notes that the rules can be used as "discrete" functions as well, like so:


Also, they note that you can use any native php function that permits a single parameter ... for example: isset() or empty().

However, you specifically mentioned Alpha Numeric and Right Size:


Hope this helps, Good Luck.


"Note: These rules can also be called as discrete functions. For example:"

Oh, ok ^^

And another question is, Is there a possibility to throught some Error messages after the check, if needed? If pass a normal form throught the form validation, i can use the validation_errors() function.


Uhm ... That's a good question. I'm not sure how you pass in the extra parameter on functions like exact_length. As for error messages, I believe you would be looking for:

$this->form_validation->set_message('rule', 'Error Message');

See the section on "Setting Error Messages".

Mh... ok, I tried this before by myself. And get no result.

Now I wrote my on function ^^ Thanx anyaway.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.