Re: Quickform checkboxes/groups and client validation

From: Date: Sat, 11 Oct 2003 12:29:38 +0000
Subject: Re: Quickform checkboxes/groups and client validation
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8378@lists.php.net to get a copy of this message
<graeme@inetix.com.au> wrote : > Hi. I've been poking around in Quickforms trying to get client-side > validation working for a group of checkboxes. >> From the example code: > $checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, > 'A'); > $checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, > 'B'); > $checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, > 'C'); > $checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, > 'D'); > $form->addGroup($checkbox, 'destination', 'Destination:', > array('&nbsp;', > '<br />')); > $form->addGroupRule('destination', 'Please check at least two boxes', > 'required', null, 2); > > If I make add 'client' to the addGroupRule() method, QuickForms outputs > Javascript on the page as expected > var field = frm.elements['destination']; > var regex = /(\s|\S)/; > if (!regex.test(value) && !errFlag['destination']) { > errFlag['destination'] = true; > _qfMsg = _qfMsg + '\n - Please check at least two boxes'; > } > > However. this is not correct code for checkboxes. Looking at QuickForm.php > is appears that because I've created a group, this is the javascript that is > displayed as opposed to the javascript for a checkbox. > > Is there was way to create the group of checkboxes yet still have client > side validation? > > I'm attempting this using the Smart static stuff BTW although I don't expect > this to make any difference. Hi Graeme, Could you file a bug for this please so that we remember to fix that for the next release. Thanks, Bertrand Mansion Mamasam

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