QuickForm javascript / setDefaults
| From: | Peter McMillan | Date: | Wed, 07 Apr 2004 15:59:14 +0000 |
| Subject: | QuickForm javascript / setDefaults | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11713@lists.php.net to get a copy of this message | ||
I have a QuickForm working correctly. My app is a quiz. The user
registers, takes the quiz and is passed back to the form to start
again if they don't pass the quiz. I record the randomly generated
set of questions and the user info to a table for each quiz attempt.
I've created via setDefaults, $_SESSION vars that contain the First,
Last, etc.
My problem is that when the user is returned to the form the
javascript errors are displayed for the required fields and the
setDefaults values are filling in the form fields correctly. The result
being that I've got bogus error messages being displayed; a distracting
UI.
I'm not sure where to begin my troubleshooting process.
Here's a sample entry for a field in the form:
$form->addElement('text', 'Last', 'Last:');
$form->addRule('Last', 'Please enter your Last name.', 'required',
false, 'client');
$form->addRule('Last', 'Invalid characters in Last name.', 'regex',
'/^[ a-zA-Z\',.-]+$/','client');
Any suggestions would be greatly appreciated.
Peter