Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do I detect and handle empty form fields?

by chromatic (Archbishop)
on Apr 17, 2000 at 01:49 UTC ( [id://7780]=note: print w/replies, xml ) Need Help??


in reply to How do I detect and handle empty form fields?

If you're using CGI.pm (and you should), you can check to see if a field is empty with the following code:
if (defined $q->param("this_is_your_field_name")) { # do something spectacular } else { $fieldempty = 1; # fail spectacularly }
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:
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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found