Okay, let me try again.
The code below sends the User to the desired page regardless of what is in the text box, and even if it is empty.
This means that I have not put the right information in the right place in this code.
I want it so that the User Must enter the correct information
if not, the User will receive a message such as; “Please enter the correct information”
if so, the User will be sent to the specified page
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Answer Validation</title>
<style type="text/css">
<!--
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: small;
}
-->
</style>
</head>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function validateForm()
{
var count=0;
var msg="correct";
for(i=0;i<=4;i++)
{
if(document.UD.elements[i].value=="correct")
{
count=1;
msg=msg+"\n"+document.UD.elements[i].name;
}
else if((i>3) && (count==0))
{
return(true);
}
}
for(i=0;i<=4;i++)
{
if(document.UD.elements[i].value=="correct")
{
alert("Please enter Correct Answer\n "+msg);
document.UD.elements[i].focus();
return(false);
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="success.html" NAME="UD">
<TABLE ALIGN="CENTER">
<TR>
<TD><span class="style1">Enter Correct Answer </span></TD>
<TD><INPUT NAME="correct" TYPE="TEXT" size="40"></TD><TD><INPUT TYPE="SUBMIT" VALUE="Go"
onClick="return validateForm()"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Will someone please help me make this so that it works the way that I need it to?
Charles