John Pretti wrote:

Hi all,

Hello,

What is the best way to validate a form element? I am using the following
code to generate a set of radio buttons; how can I ensure that one of the
buttons is checked before processing the rest of the script?


Assuming %label is

hw => 'H W here',
nw => 'North West',
etc...

you could simply do:

my $promdir = CGI::param('promdir');
die 'Invalid input' if !exists $label{$promdir};


print   $q->start_multipart_form,
                $q->p("Please select a directory to promote the file:"),
                $q->radio_group (
                        -name=>'promdir',
                        -values=>

I'd use -values => [keys %label], for consistancy and sanity's sake

['hw','nw','sw','swmfis','swunifi','swwebcaaf'],
-labels=>\%label,
-default=>'selected',
-linebreak=>'true'),
$q->br,
$q->submit('Promote'),
$q->end_form;
Thanks in advance,

HTH Lee.M - JupiterHost.Net

John

-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to