Re: HTML_QuickForm: Set field required based on the input in an other field?
| From: | Mark Wiesemann | Date: | Wed, 26 Jul 2006 18:30:47 +0000 |
| Subject: | Re: HTML_QuickForm: Set field required based on the input in an other field? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24782@lists.php.net to get a copy of this message | ||
Markus Ernst wrote:
> There is a contact form with some options for the user to choose what
> kind of information he/she wishes, for example:
>
> [ ] Name
> [ ] Address
> [ ] E-Mail*
>
> Please send me:
> [ ] your e-mail newsletter
> [ ] your catalogue
>
> Now for sending the catalogue I need the name and address, so I would
> like to define a rule to make those required only if "your catalogue" is
> checked. Is this possible, maybe using the compare rule? Or do I have to
> hard-code this separately for both client and server sides?
The compare rule is not sufficient for this. You need to define your own
rule, if you want also for the client side. Documentation for own rules:
http://pear.php.net/manual/en/package.html.html-quickform.intro-validation.php#package.html.html-quickform.intro-validation.rules.functions
Regards,
Mark