[QF] Partial JS validation of a Date element

From: Date: Wed, 17 Mar 2004 15:31:49 +0000
Subject: [QF] Partial JS validation of a Date element
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11355@lists.php.net to get a copy of this message
Hi, I have a standard Date element on my form. It is defined as:- $this->addElement('date', 'eventDate', "Date of Event", array('format' => 'dMY', 'language' => $_SESSION['_lang'], 'minYear' => date('Y'), 'maxYear' => '1902', 'addEmptyOption' => true)); As part of the client side validation I wanted to ensure a user cannot select a date in the future. So I set about adding a numeric-range check on the month field to begin with. I've tried a couple of attempts of how to validate this sub-element of the Date. Neither seem to be reacting upon selection of an invalid month. $this->addGroupRule('eventDate', array( 'M' => array( array("Can't be in the future", 'NumericRange', array('min' => 1, 'max' => date('n')), 'client') ) )); This was a long shot... $this->addRule('eventDate[M]', "Can't be in the future", 'NumericRange', array('min' => 1, 'max' => date('n')), 'client'); NB: The NumericRange rule comes from the demonstration of how to write a new rule example. Viewing the HTML/JS generated code on the webpage, it seems that the rule is not even getting written in to the JavaScript validate_*() method(!) What could be causing this issue? Thanks in advance, -- Mike Carter __________________________________________________________________________________________ This message is confidential. Unless you are the named addressee or their delegated representative you may not use, disclose, or copy the contents of the e-mail. If you are not the named addressee please notify the sender immediately and delete the material from your computer. Any views or opinions contained in this e-mail are solely those of the author unless expressly stated otherwise. This email has been scanned for all viruses by the MessageLabs Email Security System __________________________________________________________________________________________

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