Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

CGI::QuickForm might be a nice option

by dazzle (Sexton)
on Sep 26, 2004 at 23:33 UTC ( #394024=note: print w/replies, xml ) Need Help??

in reply to Multiple testing methods

You didn't say that using another Perl module was out of the question, so how about taking a look at CGI::QuickForm? If you create the form and supply the validation criteria in the form of a subroutine, it will automatically validate and highlight the error fields for you. Here's a snippet from the CGI::QuickForm perldoc:


Optional subroutine reference. This routine is called after each individual field has been validated. It is given the fields in a name=>value hash. It should either return a simple true (valid) or false (invalid) or a two element list, the first element being a true/false value and the second value either an empty string or an (html) string which gives the reason why the record is invalid. Typically it may have this structure:
sub valid_record { my %field = @_ ; my $valid = 1 ; my $why = '' ; # Do some multi-field validation, e.g. if( $field{'colour'} eq 'blue' and $field{'make'} eq 'estate' ) { $valid = 0 ; # No blue estates available. $why = '<b><i>No blue estates available</i></b>' ; } # etc. ( $valid, $why ) ; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://394024]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2019-12-07 01:01 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (160 votes). Check out past polls.