Menu
Gang,
I have 3 html pages that use the same validation code. Two of three pages work fine. For some strange reason the third html page will not execute the validation code. Also, there are no form tags inside of any form tags.
The ERROR I get is ‘form2’ is undefined
Here is the code:
[CODE]
<script language=”JavaScript”>
function Validate(form2)
{
//alert(document.form2.PegNumberDrawn.value);
if(document.form2.PegNumberDrawn.value = ”)
{
alert(“Please choose the Peg Number Drawn for this angler.”);
document.form2.PegNumberDrawn.focus();
return false;
}
else
{
document.form2.submit();
}
}
</script>
[CODE]
<script language="JavaScript">
function Validate()
{
//alert(document.form2.PegNumberDrawn.value);
if(document.form2.PegNumberDrawn.value = '')
{
alert("Please choose the Peg Number Drawn for this angler.");
document.form2.PegNumberDrawn.focus();
return false;
}
else
{
document.form2.submit();
}
}
</script>
[/CODE]
[CODE]
<form method="post" action="AssignPegNumberDrawnUpdate_Second.asp" name="form2">
<table>
<tr>
<td>
<input type="hidden" value="<%=RSCustomers("CustomerId")%>" name="CustomerId">
<input type="hidden" value="<%=FishId%>" name="FishId">
<input type="hidden" value="Second" name="DatabaseNumber">
<font color="white" size="5"><u><b>Peg Number Drawn<b></u></font>
<br>
<select NAME="PegNumberDrawn" SIZE="1">
<option VALUE="<%=PegNumberDrawn%>"><%=PegNumberDrawn%>
<option VALUE="0">0
<option VALUE="1">1
<option VALUE="2">2
<option VALUE="3">3
<option VALUE="4">4
<option VALUE="5">5
<option VALUE="6">6
<option VALUE="7">7
<option VALUE="8">8
<option VALUE="9">9
<option VALUE="10">10
</select>
</td>
</tr>
</table>
<input type="BUTTON" onclick="Validate(form2);return false;" value="Update Peg" name="submit1" align="left">
</form>
[/CODE]
function Validate()
<i> </i>{
<i> </i> var sel=document.form2.PegNumberDrawn;
<i> </i> if(sel.options[sel.selectedIndex].value == '')
<i> </i> {
<i> </i> alert("Please choose the Peg Number Drawn for this angler.");
<i> </i> document.form2.PegNumberDrawn.focus();
<i> </i> return false;
<i> </i>}
<i> </i> else
<i> </i>{
<i> </i>document.form2.submit();
<i> </i> }
<i> </i> }
<input type="BUTTON" onclick="return Validate(form2);" value="Update Peg" name="submit1" align="left">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function Validate()
<i> </i>{
<i> </i> var sel=document.form2.PegNumberDrawn;
<i> </i> if(sel.options[sel.selectedIndex].value == '')
<i> </i> {
<i> </i> alert("Please choose the Peg Number Drawn for this angler.");
<i> </i> document.form2.PegNumberDrawn.focus();
<i> </i> return false;
<i> </i>}
<i> </i> else
<i> </i>{
<i> </i>document.form2.submit();
<i> </i> }
<i> </i> }
</script>
<style type="text/css">
</style>
</head>
<body>
<form method="post" action="AssignPegNumberDrawnUpdate_Second.asp" name="form2">
<table>
<tr>
<td>
<input type="hidden" value="<&#37;=RSCustomers("CustomerId")%>" name="CustomerId">
<input type="hidden" value="<%=FishId%>" name="FishId">
<input type="hidden" value="Second" name="DatabaseNumber">
<font color="white" size="5"><u><b>Peg Number Drawn<b></u></font>
<br>
<select NAME="PegNumberDrawn" SIZE="1">
<option VALUE="">PegNumberDrawn
<option VALUE="0">0
<option VALUE="1">1
<option VALUE="2">2
<option VALUE="3">3
<option VALUE="4">4
<option VALUE="5">5
<option VALUE="6">6
<option VALUE="7">7
<option VALUE="8">8
<option VALUE="9">9
<option VALUE="10">10
</select>
<i> </i></td>
</tr>
</table> <br/>
<input type="BUTTON" onclick="return Validate();" value="Update Peg" name="submit1" align="left">
</form></body>
</html>
[CODE] <script language="JavaScript">
function Validate(form2)
{
if(document.form2.PegNumberDrawn.value == '')
{
alert("Please choose the Peg Number Drawn for this angler.");
document.form2.PegNumberDrawn.focus();
return false;
}
else
{
document.form2.submit();
}
}
</script>
[/CODE]
[CODE]
<form method="post" action="AssignPegNumberDrawnUpdate_Second.asp" name="form2" onsubmit="return Validate(document.form2.PegNumberDrawn.value);">
<table>
<tr>
<td>
<input type="hidden" value="<%=RSCustomers("CustomerId")%>" name="CustomerId">
<input type="hidden" value="<%=FishId%>" name="FishId">
<input type="hidden" value="First" name="DatabaseNumber">
<font color="white" size="5"><u><b>Peg Number Drawn<b></u></font>
<br>
<select NAME="PegNumberDrawn" SIZE="1">
<option VALUE="<%=PegNumberDrawn%>"><%=PegNumberDrawn%>
<option VALUE="0">0
<option VALUE="1">1
<option VALUE="2">2
<option VALUE="3">3
<option VALUE="4">4
<option VALUE="5">5
<option VALUE="6">6
<option VALUE="7">7
<option VALUE="8">8
<option VALUE="9">9
<option VALUE="10">10
</select>
</td>
</tr>
</table>
<input type="BUTTON" onclick="Validate(form2);return false;" value="Update Peg" name="submit1" align="left">
</form>
[/CODE]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function Validate(f)
<i> </i>{
<i> </i> var sel=f.PegNumberDrawn;
<i> </i> if(sel.options[sel.selectedIndex].value == '')
<i> </i> {
<i> </i> alert("Please choose the Peg Number Drawn for this angler.");
<i> </i> f.PegNumberDrawn.focus();
<i> </i> return false;
<i> </i>}
<i> </i>return true;
<i> </i> }
</script>
<style type="text/css">
</style>
</head>
<body>
<form method="post" action="AssignPegNumberDrawnUpdate_Second.asp" name="form2" onsubmit="return Validate(this);">
<table>
<tr>
<td>
<input type="hidden" value="<&#37;=RSCustomers("CustomerId")%>" name="CustomerId">
<input type="hidden" value="<%=FishId%>" name="FishId">
<input type="hidden" value="Second" name="DatabaseNumber">
<font color="white" size="5"><u><b>Peg Number Drawn<b></u></font>
<br>
<select NAME="PegNumberDrawn" SIZE="1">
<option VALUE="">PegNumberDrawn
<option VALUE="0">0
<option VALUE="1">1
<option VALUE="2">2
<option VALUE="3">3
<option VALUE="4">4
<option VALUE="5">5
<option VALUE="6">6
<option VALUE="7">7
<option VALUE="8">8
<option VALUE="9">9
<option VALUE="10">10
</select>
<i> </i></td>
</tr>
</table> <br/>
<button type="submit"value="Update Peg" name="submit1">Update Peg</button>
</form></body>
</html>
If you still get undefined then there is a problem with the html, 0.1.9 — BETA 5.6