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

#1
[eluser]noro[/eluser]
Hey!

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.

Greetz
Noro

#2
[eluser]Michael;[/eluser]
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:

Code:
$this->form_validation->required($string);

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:

Code:
$this->form_validation->alpha_numeric($var);
$this->form_validation->exact_length($var);


Hope this helps, Good Luck.

Michael;

#3
[eluser]noro[/eluser]
"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.

#4
[eluser]Michael;[/eluser]
Greetings,

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:

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

See the section on "Setting Error Messages".

#5
[eluser]noro[/eluser]
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.