<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation {
protected $CI;
public function __construct() {
$this->CI =& get_instance();
// Validation rules can be stored in a config file.
$this->_config_rules = $rules;
// Automatically load the form helper
$this->CI->load->helper('form');
// Set the character encoding in MB.
if (function_exists('mb_internal_encoding'))
{
mb_internal_encoding($this->CI->config->item('charset'));
}
log_message('debug', "Form Validation Class Initialized");
}
function alpha_space($str) {
$this->CI->form_validation->set_message('alpha_space', 'The %s may only contain Alpha Characters and Spaces.');
if (trim($str) !== "" & Is_a_Letter_or_Space_validation($str)) {
return TRUE;
}
else {
return FALSE;
}
}
function Is_a_Letter_or_Space_validation($inputbox) {
$teststring = Trim($inputbox);
if ($teststring == "") {
return False;
}
$i = 0;
while ($i <= strlen($teststring) - 1) {
$c = strtolower(substr($teststring,$i,1));
if ($c <> "a" & $c <> "b" & $c <> "c" & $c <> "d" & $c <> "e" & $c <> "f" & $c <> "g" & $c <> "h" & $c <> "i" & $c <> "j" & $c <> "k" & $c <> "l" & $c <> "m" & $c <> "n" & $c <> "o" & $c <> "p" & $c <> "q" & $c <> "r" & $c <> "s" & $c <> "t" & $c <> "u" & $c <> "v" & $c <> "w" & $c <> "x" & $c <> "y" & $c <> "z" & $c <> " ") {
return False;
}
$i = $i + 1;
}
return True;
}
}