CodeIgniter Forums
standard Form Validation for textareas - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: standard Form Validation for textareas (/showthread.php?tid=66510)



standard Form Validation for textareas - dbrooke - 10-28-2016

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


RE: standard Form Validation for textareas - dbrooke - 10-31-2016

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;
 
       }
 
   }