Quickform date required validation

From: Date: Thu, 13 Nov 2003 15:37:06 +0000
Subject: Quickform date required validation
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8889@lists.php.net to get a copy of this message
Hi all, I have a 'date' element on my form. Defined as:- $this->addElement('date', 'dob', $language['L_DateOfBirth'], array('language' => $_SESSION['_lang'], 'format' => 'dmY', 'minYear' => date('Y', strtotime('-17 years')), 'maxYear' => '1901', 'addEmptyOption' => true)); I want to ensure a user enters a valid date - which involves picking a value from each of the three select boxes. From the 'date' element source code I can see that the element is effectively a group of elements anyway. What sort of rule needs to be defined to enforce a user to complete the date element in full? The rules-builtin.php example doesn't cover validating a 'date' element. Using this... $this->addRule('dob', $language['L_RequireDOB'], 'required', null, 'client'); ...provides the is-required asteriks on the form but no validation seems to get performed upon submitting the form, I can freely move to the next page. Using the addGroupRule() method instead does provide the validation message, but only cares about me filling out the first element (due to the '1' in the following rule). $this->addGroupRule('dob', $language['L_RequireDOB'], 'required', null, 1, 'client'); Is there a defined way to apply the rule to the whole group, or do I need to do three 'required' definitions? Kind regards, -- Mike Carter ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________

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