Re: QF add/registerRule() to get client side validation
| From: | Alexey Borzov | Date: | Fri, 09 Sep 2005 16:44:31 +0000 |
| Subject: | Re: QF add/registerRule() to get client side validation | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20886@lists.php.net to get a copy of this message | ||
Hi,
Kyungho Baek wrote:
I'm haing a problem using registerRule to validate a form. below (140-147) comes after adding all the elements. In line 141, i register a rule which is a function shown further below (150-157) that will check a value - from 'date', QuickForm element... 140 $this->qf->applyFilter(array('subject', 'content'), 'trim'); // why doesn't work? 141 $this->qf->registerRule('isValidDate', 'callback', '_isValidDate', 'EventBlankForm'); 142 $this->qf->addRule('subject', 'Subject is missing.', 'required'); 143 $this->qf->addRule('sTime', 'Invalid start date.', 'isValidDate'); 144 $this->qf->addRule('eTime', 'Invalid end date.', 'isValidDate'); 145 //$this->qf->addRule('subject', 'Subject is missing.', 'required', null, 'client'); 146 //$this->qf->addRule('sTime', 'Invalid start date.', 'isValidDate', null, 'client'); 147 //$this->qf->addRule('eTime', 'Invalid end date.', 'isValidDate', null, 'client'); ... 150 function _isValidDate($value) 151 { 152 //print_r($value); 153 //echo "<br>".$value['m']." - ".$value['d']." - ".$value['Y']; 154 if ($value['m'] != '' && $value['d'] != '' && $value['Y'] != '') { 155 return checkdate($value['m'], $value['d'], $value['Y']); 156 } 157 } * $this->qf is a instance of QuickForm and above two segments are in a class called EventBlankForm. I have a following line in a different file...after which database queries come. ... if ( isset($_REQUEST['submit']) && $form->qf->validate() ) { ... when i run this code with empty subject or/and invalid date (2005-9-31), it will not pass "if (...)" AND error message appears as expected. If i comment out lines 142-145 and un-comment 145-147 AND run the code same way, i don't get javascript action at all...server-side validation kicks in instead. what do you suggest to troubleshoot this?1) Do you really expect QuickForm to magically write a Javascript date validation function for you? 2) What's the point of posting several pages of generated code?