Hello,
I have a script that checks two radio buttons. If a certain one is checked, the script proceeds to check a text field to make sure that the visitor has inputted data and if not, displays an alert. This part works fine, but after the alert has been displayed, the script immediately committs the record to the database. I want the script to stop and force the visitor to input the required data before committing the record to the database. Here is the code:
<HTML>
<head>
<title>Employee Sign Out Board</title>
</head>
<BODY bgcolor="#D9D9FF">
<SCRIPT language="JavaScript">
<!--
function InOut() {
if (document.WhereAreYou.elements[1].checked) {
if (document.WhereAreYou.Destination.value==""
{
alert("You must input your destination when posting an Out of Office Record!"
;
return false;
}
else
return true;
}
}
//-->
</SCRIPT>
<table width="664" border="0" cellpadding="0" cellspacing="0" height="379">
<tr bgcolor="#D9D9FF">
<td height="1" valign="top" colspan="2" width="752">
<p align="center">
<img border="0" src="images/title2.gif" width="750" height="100" align="left">
</td>
</tr>
<td width="84">
<td width="666" bgcolor="#FFFFFF">
<blockquote>
<h1><font face="Tahoma">Edit Office Status:</font></h1>
<p><font face="Tahoma"><b><i>Note:</i></b> If you are posting an
"In Office" status, you may click submit to commit the default
values currently posted in this form. If you are posting an "Out of
Office Status", you must edit the default values for all fields.</font></p>
<FORM Name="WhereAreYou" method="POST" action="EBoard2.asp">
<p>
<font face="Tahoma"><b>In Office:</b>
<INPUT TYPE="radio" name="rYesNo" value="In" checked>
<b>Out of Office:</b>
<INPUT TYPE="radio" name="rYesNo" value="Out">
</font>
</p>
<P>
<font face="Tahoma"><b>Destination: </b><TEXTAREA rows="1" cols="40" NAME="Destination" TYPE="text" SIZE="60" VALUE=""></textarea>
</font>
<P>
<font face="Tahoma"><b>Estimated Return Time:</b>
<INPUT TYPE="text" name="EstimatedReturnTime" size="10" value="00/00/00; 0:00"></font>
<font face="Tahoma"><b>Date/Time Sign:</b>
<INPUT TYPE="text" name="DateTimeSignOut" size="14" value="<%=Now()%>">
</font>
<p><input type="submit" value="Submit" name="B1" onclick="InOut();"><input type="reset" value="Reset" name="B2"></p>
<input type="hidden" name="LastEdit" value="<%=Request("LastEdit"
%>"><input type="hidden" name="EmpID" value="<%=Request("EmpID"
%>">
</FORM>
</BODY>
</HTML>
Any help is greatly appreciated.
I have a script that checks two radio buttons. If a certain one is checked, the script proceeds to check a text field to make sure that the visitor has inputted data and if not, displays an alert. This part works fine, but after the alert has been displayed, the script immediately committs the record to the database. I want the script to stop and force the visitor to input the required data before committing the record to the database. Here is the code:
<HTML>
<head>
<title>Employee Sign Out Board</title>
</head>
<BODY bgcolor="#D9D9FF">
<SCRIPT language="JavaScript">
<!--
function InOut() {
if (document.WhereAreYou.elements[1].checked) {
if (document.WhereAreYou.Destination.value==""
alert("You must input your destination when posting an Out of Office Record!"
return false;
}
else
return true;
}
}
//-->
</SCRIPT>
<table width="664" border="0" cellpadding="0" cellspacing="0" height="379">
<tr bgcolor="#D9D9FF">
<td height="1" valign="top" colspan="2" width="752">
<p align="center">
<img border="0" src="images/title2.gif" width="750" height="100" align="left">
</td>
</tr>
<td width="84">
<td width="666" bgcolor="#FFFFFF">
<blockquote>
<h1><font face="Tahoma">Edit Office Status:</font></h1>
<p><font face="Tahoma"><b><i>Note:</i></b> If you are posting an
"In Office" status, you may click submit to commit the default
values currently posted in this form. If you are posting an "Out of
Office Status", you must edit the default values for all fields.</font></p>
<FORM Name="WhereAreYou" method="POST" action="EBoard2.asp">
<p>
<font face="Tahoma"><b>In Office:</b>
<INPUT TYPE="radio" name="rYesNo" value="In" checked>
<b>Out of Office:</b>
<INPUT TYPE="radio" name="rYesNo" value="Out">
</font>
</p>
<P>
<font face="Tahoma"><b>Destination: </b><TEXTAREA rows="1" cols="40" NAME="Destination" TYPE="text" SIZE="60" VALUE=""></textarea>
</font>
<P>
<font face="Tahoma"><b>Estimated Return Time:</b>
<INPUT TYPE="text" name="EstimatedReturnTime" size="10" value="00/00/00; 0:00"></font>
<font face="Tahoma"><b>Date/Time Sign:</b>
<INPUT TYPE="text" name="DateTimeSignOut" size="14" value="<%=Now()%>">
</font>
<p><input type="submit" value="Submit" name="B1" onclick="InOut();"><input type="reset" value="Reset" name="B2"></p>
<input type="hidden" name="LastEdit" value="<%=Request("LastEdit"
</FORM>
</BODY>
</HTML>
Any help is greatly appreciated.