Welcome Guest, Not a member yet? Register   Sign In
Help with password validation rules
#1

[eluser]bigspring[/eluser]
Hi guys,

I've getting well into the swing of using CodeIgniter now. Excellent framework! I have an interesting problem I can't quite work out from the documentation and wondered if one of the community can help.

I have an "Add User" form. I have validation set up on all fields, all working fine.

The idea is that if an administrator is editing somebody else's user account, they shouldn't have to populate the user's password (or any other) to edit their name / email address / etc.

What I want to do is have a form validation function that checks to see if the password field has been populated. I it has, then it should run the other rules I have specified (min length, max length, and a check that both password fields match). If it hasn't, it shouldn't run any further validation rules.

Any ideas?

Thanks,


Jon
#2

[eluser]Akinzekeel[/eluser]
How about something like:

Code:
if($this->input->post("password") !== FALSE) {
$this->form_validation->set_rules("your other rules here...");
}

$this->form_validation->set_rules("fields which are always validated here...");

if($this->form_validation->run()) {
...
} else {
...
}
#3

[eluser]bigspring[/eluser]
A perfectly simple solution that was staring me in the face. Thanks for the help!




Theme © iAndrew 2016 - Forum software by © MyBB