Welcome Guest, Not a member yet? Register   Sign In
Cannot execute MY_Form_validation
#8

[eluser]Adam_R[/eluser]
OK, I have got this to work with that code:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation
{

function valid_us_date($str)
{
  if (! preg_match("/^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$/", $str)){
   $this->set_message('valid_us_date', 'Invalid DOB format.');
   return FALSE;
  }
  else {

   return TRUE;
  }

}


function valid_exp_date($str)
{
  if (! preg_match("/^[0-9]{1,2}/[0-9]{4}$/", $str)){
   $this->set_message('valid_exp_date', 'Invalid expiration date.');
   return FALSE;
  }
  else {

   return TRUE;
  }

}


function valid_phone($str)
{
  if (! preg_match("/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/", $str)){
   $this->set_message('valid_phone', 'Invalid phone number format.');
   return FALSE;
  }
  else {

   return TRUE;
  }

}


function valid_ssn($str)
{
  if (! preg_match("/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/", $str)){
   $this->set_message('valid_ssn', 'Invalid Social Security Number.');
   return FALSE;
  }
  else {

   return TRUE;
  }

}

function valid_zip($str)
{
  if (! preg_match("/^[0-9]{5}$/", $str)){
   $this->set_message('valid_zip', 'Invalid ZIP code.');
   return FALSE;
  }
  else {

   return TRUE;
  }

}

}


Messages In This Thread
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 02:23 PM
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 04:16 PM
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 05:10 PM
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 05:13 PM
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 08:26 PM
Cannot execute MY_Form_validation - by El Forum - 10-19-2012, 11:13 PM
Cannot execute MY_Form_validation - by El Forum - 10-22-2012, 09:27 AM
Cannot execute MY_Form_validation - by El Forum - 10-22-2012, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB