Re: Quickform and dependent validation.

From: Date: Mon, 24 Feb 2003 13:48:50 +0000
Subject: Re: Quickform and dependent validation.
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3911@lists.php.net to get a copy of this message
<user@domain.invalid> wrote : > Hello, > > Can somebody give an example on how to validate > several interdepence elements? > > Example: > > $form = new HTML_QuickForm(); > > $form->addElement('text', 'text1', 'enter number1'); > $form->addElement('text', 'text2', 'enter number2'); > > $form->addRule('text1', 'must be numeric.', 'numeric'); > $form->addRule('text2', 'must be numeric.', 'numeric'); > > [...] > > There should only be an error message, when no field is filled. > > text1=xy, text2=null => true > text1=null, text2=xy => true > text1=null, text2=null => false > > I`ve tried to group this elements, but when i define a rule > with 'required' every field has to be field. 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'); Bertrand Mansion Mamasam

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