12-24-2011, 11:51 AM
[eluser]Unknown[/eluser]
Hello I want to create my form validation.
This is libraries/my_form_validation.php:
And use controler method
My form valdiation is not work.
I test preg_match in test.php(outside ci) and add some text and work, no problem
but in codeigniter not receive
Where am I wrong?
Thank you
Hello I want to create my form validation.
This is libraries/my_form_validation.php:
Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class My_Form_validation extends CI_Form_validation {
function __construct() {
parent::__construct();
$CI = & get_instance();
}
// --------------------------------------------------------------------
/**
*/
function validation_text($str) {
$CI->form_validation->set_message('validation_text', 'Incorrect Cyrillic text.');
return (preg_match("/^[a-zA-Z\p{Cyrillic}0-9\s\-\.\!\?]+$/u", $str)) ? TRUE : FALSE;
}
}
And use controler method
Code:
$this->load->library('form_validation');
$this->load->library('my_form_validation');
$this->form_validation->set_rules('newstitle', 'News title', 'trim|required|min_length[10]|validation_text[newstitle]');
if ($this->form_validation->run()) { .........
My form valdiation is not work.
I test preg_match in test.php(outside ci) and add some text and work, no problem
but in codeigniter not receive
Where am I wrong?
Thank you