Welcome Guest, Not a member yet? Register   Sign In
standard Form Validation for textareas
#1

Hello, what do you all use for set_rules for a textarea:

I have so far:

PHP Code:
$this->form_validation->set_rules('f_why''Why or why not?', array('trim','max_length[400]', array('customAlpha','customAlpha'))); 


However, I'm thinking this won't work, or I'll have to edit my customAlpha function to get it to work right with carriage returns and such.

Thanks,
Donovan
Reply
#2

This is what I have come up with.. seems to work:

PHP Code:
if ( ! function_exists('customAlpha')) {
 
   function customAlpha($str)
 
   {
 
       if (!preg_match('/^[a-zA-Z0-9 .,\-\']*$/m'$str)) {
 
           return FALSE;
 
       } else {
 
           return TRUE;
 
       }
 
   }

Reply




Theme © iAndrew 2016 - Forum software by © MyBB