CodeIgniter Forums
Calling index() on form validation failure - 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: Calling index() on form validation failure (/showthread.php?tid=66476)

Pages: 1 2


RE: Calling index() on form validation failure - dbrooke - 10-28-2016

Hi, sorry for the delay:
CI 3.1.

I have already added the error to /system/language/english/form_validation_lang.php

Custom Helper (which worked for non-required as a callback_ when in the controller):


PHP Code:
if ( ! function_exists('customAlpha')) {
 
   function customAlpha($str)
 
   {
 
       if (!preg_match('/^[a-z .,\-\']+$/i'$str)) {
 
           return FALSE;
 
       } else {
 
           return TRUE;
 
       }
 
   }




RE: Calling index() on form validation failure - salain - 10-28-2016

Hi,

I would try to change the function so it return true no matter what.

You should not modify any files in the system folders EVER.


RE: Calling index() on form validation failure - dbrooke - 10-31-2016

salain, that helped once again. Problem was the regex. This is what I have ended up with....
seems to work with textareas as well:


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