Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by Greg Harper (Initiate)
on Oct 02, 2003 at 18:09 UTC ( [id://296002]=note: print w/replies, xml ) Need Help??


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

This is how i have been dealing with empty form fields:

# If certain fields are blank, then give a "blank form" response &missing_info_error ("Date") unless $FORM{'date'}; &missing_info_error ("Name") unless $FORM{'name'}; &missing_info_error ("Eng/Rig") unless $FORM{'engorrig'}; &missing_info_error ("Engine Model") unless $FORM{'em'}; &missing_info_error ("Test Stand or Build Cell") unless $FORM{'tsbc'}; &missing_info_error ("Time Lost") unless $FORM{'tl'};

Then output is in a HTML page

Update: mandog raised the issue that this approach fails if a legitimate field value is zero. In such cases, a missing field error is posted, even though the field exists, thus reinforcing the case for using CGI.pm

Edited by davido: Added code tags. Removed duplicate submission. Directed readers to further clarification.

Replies are listed 'Best First'.
Re: Answer: How do I detect and handle empty form fields?
by mandog (Curate) on Oct 02, 2003 at 18:45 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found