• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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