HTML:

Thanks for your inquiry, but there were error(s):

(Bold fields are mandatory)
Send To:
First Name:
Last Name:
Company:
Announcements:
CSS: div.frow { clear: both; padding-top: 9px; } div.frow span.label { float: left; width: 80px; text-align: right; font-family: arial, helvetica, sans-serif; font-size: 11px; padding-top: 3px; } div.frow span.blabel { float: left; width: 80px; text-align: right; font-family: arial, helvetica, sans-serif; font-size: 11px; font-weight: bold; padding-top: 3px; } div.frow span.frm { float: right; width: 500px; text-align: left; font-family: arial, helvetica, sans-serif; font-size: 11px; } PERL: #first, validates input with validate module my ($error, @errors, @errorlist); my $sendto = $query->param('sendto'); my $fifvalues = { sendto => $sendto }; #use HTML::FillInForm for selects and checkboxes (my $first, $error)= Validate->limitedtext ($query->param('first'),20,1); if ( $error-> { msg } ) { push @errors, "First name $error->{ msg }" } (my $last, $error) = Validate->limitedtext ($query->param('last'),30,0); if ( $error-> { msg } ) { push @errors, "Last name $error->{ msg }" } (my $company, $error) = Validate->limitedtext ($query->param('company'),60,0); if ( $error-> { msg } ) { push @errors, "Company $error->{ msg }" } my $notify_ok = $query->param('notify_ok'); $fifvalues = { notify_ok => $notify_ok }; #handle errors and return form if necessary if (@errors) { foreach (@errors) { my %one_record = ( errormsg => $_, ); push (@errorlist, \%one_record); } $template = HTML::Template->new( filename => '/usr/www/users/somename/contact.tmpl', associate => $query, die_on_bad_params => 1); $template->param(errorlist => \@errorlist); print "Content-type: text/html\n\n"; my $html = $template->output(); if ($fifvalues) { my $form = new HTML::FillInForm; my $page = $form->fill(scalarref => \$html, fdat => $fifvalues); print $page; } else { print $html; } exit(); } VALIDATE: sub limitedtext { my ($class, $value, $len, $mand) = @_; if (!$value && $mand) { return (undef, { msg => 'cannot be blank' }); } elsif ($len && (length($value) > $len) ) { return (undef, { msg => 'is limited to '.$len.' characters.' }); } elsif ($value && $value !~ /^([.,-]*\w[\w .,-]*)$/) { return (undef, { msg => 'can only use letters, numbers, spaces and - . ,' }); } else { return "$1"; } }