Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

( #296002=categorized answer: print w/ replies, xml ) Need Help??

Q&A > CGI programming > How do I detect and handle empty form fields? contributed by Zombie Greg Harper

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.

Comment on Answer: How do I detect and handle empty form fields?
Download Code
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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-07-29 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls