in reply to How do I detect and handle empty form fields?
Since most code that doesn't use CGI.pm (and you should be using it) at least puts fields in a hash, you can store your fieldnames in an array and still do right:if (defined $q->param("this_is_your_field_name")) { # do something spectacular } else { $fieldempty = 1; # fail spectacularly }
my @fieldnames = qw( name rank serialnumber haircolor favoritebeverage + ); foreach my $field (@fieldnames) { $fieldempty = 1 unless (defined $fields{$field}); } # do something spectacular here unless a field is empty
|
|---|