Quickform group rules
| From: | Alain Williams | Date: | Sat, 07 Nov 2009 23:58:58 +0000 |
| Subject: | Quickform group rules | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30126@lists.php.net to get a copy of this message | ||
Hi,
I have a form in which there is an Email and a Phone field.
I want to ensure that I have at least one of these set, I also want
to apply some validation to the 2 fields.
Even if both fields are filled in it complains about not enough.
Can someone please tell me where I am going wrong.
BTW: I am using HTML/QuickForm.php on PHP5 (I have had to patch lots of things
to get rid of the warnings)
$contact[] = $form->addElement('text', 'Email', 'Email',
'size=50');
$form->addRule('Email', 'Invalid email address', 'email', null,
'client');
$contact[] = $form->addElement('text', 'Phone', 'Phone',
'size=20');
$form->addRule('Phone', 'Invalid phone number', 'regex',
'/^[0+][\d ]+$/', 'client');
$form->addGroup($contact, 'contact');
$form->addGroupRule('contact', 'You must enter at least one of Phone number or
Email address', 'required', null, 1, 'client');
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>