You are here: Re: [PHP] optional rule quick_form « PHP « IT news, forums, messages
Re: [PHP] optional rule quick_form

Posted by Torgny Bjers on 08/11/05 16:20

Uroš Gruber wrote:

> Torgny Bjers said the following on 11.8.2005 14:44:
>
>> I am assuming that this is after a post operation. If it's JavaScript, I
>> think the question should be directed to another list. So, if you group
>> the elements that should be validated after the checkbox has been
>> checked, you can activate/deactivate the group validation rules based on
>> the state of the checkbox. Makes sense?
>
>
> If I understand your idea the code would look like this
> $form->addElement('text', 'taxNumber', 'Tax:');
> $checkbox = &HTML_QuickForm::createElement('checkbox', 'isCompany','');
>
> if ($checkbox->getChecked()) {
> $form->addRule('taxNumber','required','Tax number is required');
> }
>
> if ($form->validate()) {
> ....


That would be the idea, yes. It was some time since worked with
Quick_Form, so there might be a specific order you need to perform the
adding of the rule in relation to the validate() method call on the
$form object.

> Btw yes it must be checked when user submit this. But If it's possible
> client option on rule, would be better.


I am not sure about this, is there even client-side validation support
in Quick_Form? Haven't really looked into this. I would suggest writing
a manual javascript evaluation for the specific fields that should be
visible when the checkbox is checked, or to have a postback between. The
JavaScript option sounds most tempting, since it makes it a bit more
user-friendly. That way you can use the JavaScript alert() function to
present the fields that have erroneous information as well as altering
styles in the fields in question to perhaps have a red border to
indicate errors.

Regards,
Torgny

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация