Re: QF: Optional Passwords & Comparison
| From: | Alexey Borzov | Date: | Wed, 23 Jun 2004 20:49:19 +0000 |
| Subject: | Re: QF: Optional Passwords & Comparison | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13289@lists.php.net to get a copy of this message | ||
Hi,
Mark Drago wrote:
I'm trying to create two password boxes that will be used for entering a password and for verifying that password. The problem I'm having arises due to the fact that in this application setting a password is optional. However, if the user enters text into _either_ text box, I want to throw an error in the case that they don't match (even if the other box is empty). I'm using the compare rule to check that they are the same, but I need it to be checked even if one of them is empty. I'm not sure how to go about this because they are not required. If a password had to be set, I would just set it to be required and move on, but the password is optional.I think the most quick and dirty solution would be to add *two* compare rules: $form->addRule(array('password', 'repeat'), '...', 'compare'); $form->addRule(array('repeat', 'password'), '...', 'compare'); This way it will fire if either of the boxes is not empty.