• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form validation rule

#1
[eluser]Unknown[/eluser]
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() {
parent::__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:

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

Neither way works.
Where do I make is_salary validation?

Thank you


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.