Welcome Guest, Not a member yet? Register   Sign In
Nested validation rules/if empty
#1

[eluser]sqwk[/eluser]
Code:
$this->form_validation->set_rules('new_password', 'Neues Password', 'matches[new_password_repeat]');

I have a rule that checks whether a password field is the same as a password_repeat field. However, since it is being used in the contect of a "Update your Profile" Page, the password field can sometimes be empty. In that case the form does not validate, however, no error messages are shown.

How can I tell CI to only check if the two fields match if the first field is actually filled in?
#2

[eluser]Colin Williams[/eluser]
Clue: You don't have to set the same rules every time.
#3

[eluser]sqwk[/eluser]
Every time? On that page it is needed every time. Wrapping the rule into an if statement does not work either:

Code:
if($this->input->post('new_password')) {
    $this->form_validation->set_rules('new_password', 'Neues Password', 'matches[new_password_repeat]');
}
#4

[eluser]Colin Williams[/eluser]
Hold on. Let me use my psychic powers to envision the rest of your code... Hummm... hummm...

You're on the right track. Just think through the logic. I'm sure you'll get there.




Theme © iAndrew 2016 - Forum software by © MyBB