Welcome Guest, Not a member yet? Register   Sign In
form validation rule

Hi, I have some doubts about using my own validation rule.

I have created a new validation rule for recognizing money:

class Salary_validation extends CI_Form_validation {

public function __construct() {

public function is_salary($input) {
$this->set_message('is_salary', 'The %s field can only contain natural or real numbers with 2 decimal houses.');
return (bool) preg_match('/^[0-9]+(\.[0-9]{0,2})?$/', $input);

In the controller used:

//way 1
$this->form_validation->set_rules('salary', 'Salary', 'trim|required|numeric|max_length[10]|is_salary');
//way 2

Neither way works.
Where do I make is_salary validation?

Thank you

Theme © iAndrew 2016 - Forum software by © MyBB