Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

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 drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2016-06-25 03:27 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (323 votes). Check out past polls.