Forms/CGI question
Mark Cyzyk
mcyzyk at tiger.towson.edu
Fri Apr 25 08:51:04 EDT 1997
Attached below is a subroutine I wrote to check whether certain fields on
a webform have been filled-in. If the specified field is blank the client
is returned an error message and is asked to go back and fill it in.
Hope this helps,
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
Mark Cyzyk, M.A., M.L.S. mcyzyk at midget.towson.edu
Albert S. Cook Library mcyzyk at tiger.towson.edu
Library and Instructional Technologies (410) 830-4285
Towson State University FAX (410) 830-3829
Towson, Maryland 21252 http://www.towson.edu/~mcyzyk
######################### SUB FIELDCHECK ##########################
# This subroutine checks to make sure the client has filled in several
# "required" fields, e.g., Last Name, First Name, Phone Number, Title,
# etc. If the client has not supplied this information, an error message
# is returned.
sub FieldCheck
{
# Here is a list of required fields:
%list = (
"Last Name", $in{last_name},
"First Name", $in{first_name},
"Library Barcode", $in{library_barcode},
"Home Phone", $in{home_phone},
"Cancel By", $in{cancel},
"Pay", $in{pay},
"Author or Editor", $in{author_or_editor},
"Title", $in{title});
while (($fieldname, $value) = each(%list))
{
if ($value eq "")
{
$required = "
The <i>$fieldname</i> field must be filled in
for your submission to be accepted.<p>
Please return to your original form,
edit it appropriately, and resubmit.";
&CgiError("Required Information is Missing!", $required);
exit 0;
}
}
}
On Thu, 24 Apr 1997, Christopher Adams wrote:
> I am writing a CGI script that will allow users to submit information
> through a web page. I want to require that certain text fields be filled
> out. From what I gather, there are no form tags that will do this. One
> example I saw used "hidden" field tags and processed the script using a
> second script, but I don't really understand how it works. Any ideas?
> Please cc to me and mail to the list, as I am on the digest. Thanks.
>
> Christopher Adams
> Automated Systems
> Oregon State Library
> chris at sparkie.osl.state.or.us
>
>
More information about the Web4lib
mailing list