quickform - checking a valid date rule for a date element
| From: | Luke Barker | Date: | Thu, 05 May 2005 10:45:23 +0000 |
| Subject: | quickform - checking a valid date rule for a date element | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19077@lists.php.net to get a copy of this message | ||
Hi,
I am using Quickform to display a date, and I want to check that the
date selected by the user is a valid-date, using checkdate() .
I have a date element, weddingdate:
$form->addElement('date', 'weddingdate', 'Wedding Date: ',
array('minYear'=>2005, 'maxYear'=>2015));
I made a custom rule - by making a function, then registering the rule:
function qfdate($somedate)
{
if ($somedate['d'] != '' && $somedate['M'] != ''
&& $somedate['Y'] != '') {
return checkdate($somedate['M'], $somedate['d'], $somedate['Y']);
//nb order!
}
return false; // its not valid
}
$form->registerRule('isadate', 'function', 'qfdate');
then attaching the Rule to the date element:
$form->addRule('weddingdate','Please enter a valid date',
'isadate');
// GroupRule or not?
But it doesnt work - I have tried with a GroupRule and that didnt work
either. When I output the parameter being passed to my function qfdate
during the validation, it is a empty string. If it is done with the
group rule the function is called 3 times as opposed to once for the
normal rule.
Any help or pointers appreciated!
thanks
Luke
--
~L~
lukebarker@gmail.com
http://www.battez.org
---------------------------------------
I'm doggone gonna be with
Some real people...
( R & E )