By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

m. lemos forms validation class

P: n/a
How do you validate a SELECT field with m. lemos forms validation
class. I want to make sure the user has selected a product and not left
the field as the default of 'Select One'.

$form->AddInput(array(
"TYPE"=>"select",
"NAME"=>"productid",
"ID"=>"productid",
"VALUE"=>"SelectOne",
"SIZE"=>1,
"OPTIONS"=>array(
"SelectOne"=>"Select One",
"1"=>"Good",
"2"=>"Better",
"3"=>"Best",
),
"ValidateAsNotEmpty"=>1,
"ValidationErrorMessage"=>"Please specify a product.",
"LABEL"=>"<u>P</u>roduct",
"ACCESSKEY"=>"P"
));

Thanks for any input you can give.
P.S. Manuel this is an awesome class. Great Work!!

James

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello,

on 12/20/2004 11:26 PM diroddi said the following:
How do you validate a SELECT field with m. lemos forms validation
class. I want to make sure the user has selected a product and not left
the field as the default of 'Select One'.

$form->AddInput(array(
"TYPE"=>"select",
"NAME"=>"productid",
"ID"=>"productid",
"VALUE"=>"SelectOne",
"SIZE"=>1,
"OPTIONS"=>array(
"SelectOne"=>"Select One",
"1"=>"Good",
"2"=>"Better",
"3"=>"Best",
),
"ValidateAsNotEmpty"=>1,
"ValidationErrorMessage"=>"Please specify a product.",
"LABEL"=>"<u>P</u>roduct",
"ACCESSKEY"=>"P"
));

Thanks for any input you can give.
I guess I need to have a FAQ system for recurring questions! ;-)

What I usually do is to have one option selected by default with an
empty string as value.

"VALUE"=>"",
"OPTIONS"=>array(
""=>"Select One",
"1"=>"Good",
"2"=>"Better",
"3"=>"Best",
),

This way the ValidateAsNotEmpty will make the class prevent the default
empty string value to be accepted.

P.S. Manuel this is an awesome class. Great Work!!


Thanks. ;-)

BTW, for comments or questions specific to the forms class, it was just
launched a forum system built in the PHP Classes site meant for authors
to provide support to their class users. For this class the forum page
is located here.

http://www.phpclasses.org/discuss/package/1/

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.