There are numerous features this provides over pure CGI.pm.use FormManager; my $query = new CGI(); my $fm = new FormManager (layout => [new FormManager::Text (name => 'phone_number', heading => 'Enter +your phone number', validate => 'phone'), new FormManager::Select (name => 'likes_ice_cream', heading => 'Do + you like ice cream?', option_list => ['Yes', 'No']), new FormManager::Hidden (name => 'action', value => 'submit_this_f +orm') ], form_submit => 'Submit this form' ); print "Content-Type: text/html\n\n"; # This script can be called in two ways # 1) Initially to get the form # 2) By submitting the form # If this is case 1) if ($query->param ('action') ne 'submit_this_form') { print $fm->getHtml(); } else { # Ensure that the input is valid. If not, re-print the form if (!$fm->processQuery()) { print $fm->getHtml(); } else { print "Your phone number is : " . $fm->getValue ('phone_number')" +. " and you " . ($fm->getValue ('likes_ice_cream') eq 'No' ? "don't l +ike ice cream." : "like ice cream."); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there room for YAHTMLM?
by Ovid (Cardinal) on Feb 27, 2003 at 21:10 UTC | |
|
Re: Is there room for YAHTMLM?
by jonadab (Parson) on Mar 01, 2003 at 19:14 UTC | |
by jbeninger (Monk) on Mar 01, 2003 at 22:24 UTC | |
by jonadab (Parson) on Mar 01, 2003 at 23:37 UTC | |
|
lots of web form validation packages already
by markjugg (Curate) on Jul 09, 2003 at 14:45 UTC |