[ back to toc ]

cgi form and required fields

Date: 2002/04/09 16:33

Q:
Hello Peter,
How can I make fields within a mailform make required fields?
I am making a form in Adobe GoLive 5.
Thank you.
*NAME-DELETED*
A:
You have to do three things:

1. Write some HTML text near the field telling the user that the field is
required.

2. Write JavaScript into the page that checks that the required fields are
all filled in and tries to prevent the user to submit a page that has not
all required fields filled in.

3. On the server the CGI program has to check that the required fields are
filled.

Regards,
Peter
Q:
Hello Peter, thanx for your answer.
Can you give me the HTML code and Java Script or tell me where I can find
this on the internet.
Thank you again.
*NAME-DELETED*

A:
Go to www.javascript.com and on the bottom select "Forms and Data
Validation" script category.

Regards,
Peter
Q:
Thanx Peter, I'm getting there.
Now I have one last question on the Javascript.
This is what I used:
<SCRIPT LANGUAGE="JavaScript">
<!function valid(form) {
var field = form.email;
var email = parseInt(field.value);
if (!email) {
alert("Om u een bevestiging te kunnen sturen is het nodig dat u uw
e-mail adres invult.");
return false;
} else if (email) {
alert("Bedankt voor uw bestelling.");
return true;
}

}
// -->
</SCRIPT>
The only thing I need now is after the
else if (email.........
How do I get the script to send the form when the email field is entered
by the customer?
*NAME-DELETED*

A:
First of all:

} else if (email) {

you do not need 'if(email)' Just say

} else {

That is what 'else' is used for. This function is called from a button
event 'OnSubmit' or something like that. If the function returns true then
the form is submitted to the server where a CGI program (or some other
program, but for the most probable case this is going to be a CGI program)
processes it and the server sends out an eMail (not the client).

To send a mail from a form you can find some scripts on

http://www.bignosebird.com/

but you will certainly tailor those. You may, if you have never programmed
CGI and Perl need the help of some local expert though.

Regards,
Peter

[ back to toc ]