Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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

by Zombie Greg Harper (Initiate)
on Oct 02, 2003 at 18:09 UTC ( #296002=categorized answer: print w/replies, xml ) Need Help??

Q&A > CGI programming > How do I detect and handle empty form fields? - Answer 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

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?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2016-09-29 19:28 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (559 votes). Check out past polls.