I have this cgi guestbook with a validation form script. What happens is, when you hit the submit button, a page loads and thanks you for your feedback. If you put any errors in the form alerts pop up and the page still loads after you close the alert boxes'. This is also posted in the cgi section, but no one was replying there. Heres the code.
<HTML>
<HEAD>
<TITLE>Guestbook Script</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<!-- VALIDATION FORM SCRIPT -->
<script language="javascript">
function validate()
{
var num=document.guess
var num2=num.email.value.indexOf("@")
var num3=num.name.value
if (num2 == -1)
{
alert("Not a valid e-mail")
submitOK="False"
}
if (num3<1 || num3>20)
{
alert("Your name must be between 1 and 20 characters'")
submitOK="False"
}
if (submitOK=="False")
{
return false
}
}
</script>
<FORM name="guess" METHOD="post" ACTION="/cgi-bin/guestbook.cgi">
<INPUT NAME="name" SIZE=50 TYPE="text"> <B>Your Name</B><BR>
<INPUT NAME="email" SIZE=50 TYPE="text"> <B>Your E-Mail Address</B><BR>
<INPUT TYPE="hidden" NAME="submitaddress" VALUE=http://www.webdeveloper.com/forum/archive/index.php/"[email protected]">
<p>
<select name="selection">
<option value="pick one" selected>Pick One
<option value="leave feedback">Leave Feedback
<option value="order">Place an Order
<option value="question">Questions'
</select> <b>Choose a subject</b><p>
<b>Write to me below:</b><br>
<TEXTAREA NAME="feedback" ROWS=10 COLS=50></TEXTAREA><P>
<CENTER>
<INPUT TYPE=submit VALUE=http://www.webdeveloper.com/forum/archive/index.php/"SEND" onclick="validate()">
<INPUT TYPE=reset VALUE="CLEAR">
</CENTER>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Guestbook Script</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<!-- VALIDATION FORM SCRIPT -->
<script language="javascript">
function validate()
{
var num=document.guess
var num2=num.email.value.indexOf("@")
var num3=num.name.value
if (num2 == -1)
{
alert("Not a valid e-mail")
submitOK="False"
}
if (num3<1 || num3>20)
{
alert("Your name must be between 1 and 20 characters'")
submitOK="False"
}
if (submitOK=="False")
{
return false
}
}
</script>
<FORM name="guess" METHOD="post" ACTION="/cgi-bin/guestbook.cgi">
<INPUT NAME="name" SIZE=50 TYPE="text"> <B>Your Name</B><BR>
<INPUT NAME="email" SIZE=50 TYPE="text"> <B>Your E-Mail Address</B><BR>
<INPUT TYPE="hidden" NAME="submitaddress" VALUE=http://www.webdeveloper.com/forum/archive/index.php/"[email protected]">
<p>
<select name="selection">
<option value="pick one" selected>Pick One
<option value="leave feedback">Leave Feedback
<option value="order">Place an Order
<option value="question">Questions'
</select> <b>Choose a subject</b><p>
<b>Write to me below:</b><br>
<TEXTAREA NAME="feedback" ROWS=10 COLS=50></TEXTAREA><P>
<CENTER>
<INPUT TYPE=submit VALUE=http://www.webdeveloper.com/forum/archive/index.php/"SEND" onclick="validate()">
<INPUT TYPE=reset VALUE="CLEAR">
</CENTER>
</FORM>
</BODY>
</HTML>