Welcome Guest, Not a member yet? Register   Sign In
Why does nor work my validation rule?
#1

[eluser]oliwin[/eluser]
Hello!
At page i have input box:
Collapse | Copy Code
<input 13px;" name="rules" id="User_agreement" value="1" type="checkbox">

<?=form_error('rules')?>


And at side php there is validation code:

Collapse | Copy Code
<?$this->form_validation->set_rules('rules', 'Согласие с правилами', 'required|callback__rules_accept');

function _rules_accept($check){

if($this->input->post('rules') && $this->input->post('rules') == 1) {
return true;
}

$this->form_validation->set_message('_email_unic', 'Необходимо подтвердить ваше согласие с правилами использования');
return false;
}
?>

But it does not work! Why? Can you explain me?
#2

[eluser]Suhas nazir[/eluser]
Hi

Please change your code like this

Here $str holds the value of your input "rules"

function _rules_accept($str){

if($str==1) {
return true;
}

$this->form_validation->set_message(‘_rules_accept’, ‘Необходимо подтвердить ваше согласие с правилами использования’);
return false;
}
#3

[eluser]jairoh_[/eluser]
there should br something like
if ( $this->validation->run() == false ) {
//show error
echo validation_error();
} else {
//proceed
}
#4

[eluser]TheFuzzy0ne[/eluser]
There are many levels of "not working", please could you be more specific? Is the rule not being called? Is it always failing? Are you not getting the error message you'd expect?




Theme © iAndrew 2016 - Forum software by © MyBB