Re: Quickform and dependent validation.

From: Date: Mon, 24 Feb 2003 15:01:23 +0000
Subject: Re: Quickform and dependent validation.
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3915@lists.php.net to get a copy of this message
<tobias.nix@web.de> wrote : > Hello, > >> Did you try: >> >> $form->addRule('text1', 'is required.', 'required'); >> $form->addRule('text1', 'must be numeric.', 'numeric'); >> $form->addRule('text2', 'is required.', 'required'); >> $form->addRule('text2', 'must be numeric.', 'numeric'); > > If tried this, but then both fields must be filled. > I am searching for a method, that only one of both fields > has to be filled, not depending on field1 or field2. > > Name Value Name Value Validate > text1 = value text2 = null true > text1 = null text2 = value true > text1 = null text2 = null false > > In my real form, i ve got 10 textfields and this form > should only be true, if one or more of these fields > are filled and value is numeric. The method addGroupRule was made for that. $field[] =& HTML_QuickForm::createElement('text', 'field1', 'Field 1'); $field[] =& HTML_QuickForm::createElement('text', 'field2', 'Field 2'); $form->addGroup($field, 'mygroup', 'Text Fields:'); $form->addGroupRule('mygroup' ,'Fill one field' ,'required', null, 1); $form->addGroupRule('mygroup' ,'Values must be numeric' ,'numeric'); Tell me if it works. Bertrand Mansion Mamasam PS: You might want to fix your clock !

« previous php.pear.general (#3915) next »