Is it possible to change the output of the matches
call when running form validation in CodeIgniter?
I'm validating a password against a confirm password box.
array(
'field' => 'userPassword',
'label' => 'Password',
'rules' => 'trim|required|matches[userConfPassword]'
)
But when the error is triggered it prints out:
The Password field does not match the userConfPassword field.
The user has no idea was userConfPassword
means and I'd like to change that to something more friendly. Reading the docs I can't find a way to do it.
Well, you can override the default message:
$this->form_validation->set_message('matches', 'the two passwords do not match|');
or some other message like that :).
I usually use that message for the "confirm password" only, though, so I set the normal password field as required and that's all, while for the confirm I have it to match the password entered, not the otherway around (or both). But that's just matter of taste I think.
For the record, it's written in this paragraph of the manual.
This code works for me:
array(
'field' => 'userPassword',
'label' => 'Password',
'rules' => 'trim|required|matches[userConfPassword]'
),
array(
'field' => 'userConfPassword',
'label' => 'Confirm Password',
'rules' => 'trim|required'
)
When the error is triggered it prints out:
The Password field does not match the Confirm Password field.