RE: [PEAR] QuickForm this.form.submit(), errors don't show up
| From: | Mark Steudel | Date: | Mon, 19 Jun 2006 20:50:27 +0000 |
| Subject: | RE: [PEAR] QuickForm this.form.submit(), errors don't show up | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24436@lists.php.net to get a copy of this message | ||
Sorry forgot to include that in my email.
============ CODE IM WORKING WITH ===================
$form =& new HTML_QuickForm('testform');
// Creates a checkboxes group using an array of separators
$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, 'ichkABC', 'ABCD:', array(' ',
'<br />'));
// At least one element is required
$form->addGroupRule('ichkABC', 'Please check at least two boxes',
'required', null, 2);
$form->addElement( 'submit', 'submitForm', 'Submit Form', array(
"onclick"=>
"this.value='Submitting form please
wait...';this.disabled=true;this.form.submit();") );
if( $form->validate() )
{
}
else
{
$form->display();
}
=============== END ==========================================
If I don't check any boxes with the below code, I don't get an error
message(server side). If I check one box, then the error message shows up.
If I remove the submit onclick javascript, the error message shows up when I
don't check any boxes and of course when I check only one box.
Mark
-----Original Message-----
From: Massimiliano Arione [mailto:garak@studenti.it]
Sent: Monday, June 19, 2006 8:13 AM
To: Mark Steudel
Cc: pear-general@lists.php.net
Subject: Re: [PEAR] QuickForm this.form.submit(), errors don't show up
Mark Steudel wrote:
> I added a little javascript to my submit button to provide feedback to the
> user when they submit a form, it also disables the submit butt. When I use
> it, the errors in the below form don't show up, is it because I'm using
the
> javascript this.form.submit()? Why would it cause the errors not to show
up?
> Example form
> $form =& new HTML_QuickForm('testform');
> // Creates a checkboxes group using an array of separators
> $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, 'ichkABC', 'ABCD:',
> array(' ', '<br />'));
> // At least one element is required
> $form->addGroupRule('ichkABC', 'Please check at least two boxes',
> 'required', null, 2);
> $form->addElement( 'submit', 'submitForm', 'Submit Form',
> array(
"onclick"=>
> "this.value='Submitting form please
> wait...';this.disabled=true;this.form.submit();") );
You MUST call $form->validate()
--
Massimiliano Arione
http://garakkio.altervista.org
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php