Hi all
The error coming up is "init is not defined". Even thought it is defined within the body tag. The whole of the code is place below. The first section of code is to check that at least one field has been changed. This prevents the query from returning all the records in the table. This is working well. The second is where I need the number validation working but the the script is says "init is not defined" I wondering is it possible to have two function validation in one form. For example Onsumbit for one function which to check for the required field and for the second Onclick to validate as a number with a maximum number of characters.
****
code
**
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkFields() {
asc_order_cd = document.myForm.asc_order_cd.selectedIndex >= 1;
site_number = document.myForm.site_number.value;
surveyorone = document.myForm.surveyorone.selectedIndex >= 1;
proj_code = document.myForm.proj_code.selectedIndex >= 1;
factual_key = document.myForm.factual_key.selectedIndex >= 1;
e1 = document.myForm.e1.value;
n1 = document.myForm.n1.value;
if ((asc_order_cd == "" && (site_number == "" && (surveyorone == ""&&(proj_code == ""&&(factual_key == "" && (e1 == ""&&(n1 == "") {
alert("Please select or enter either a ASC, Site Number, Surveyorone, Project Code, Factual Key , Easting, Northing."
return false;
}
else return true;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript" src="../buttons/validation.js">
<!--
function init() {
define('e1', 'num', 'e1', 6);
define('e2', 'num', 'e2', 6);
define('n1', 'num','n1', 7);
define('n2', 'num', 'n2', 7);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" background="../buttons/Texture_brown_051.jpg" OnLoad="init()">
<font face="Arial, Helvetica, sans-serif" size="5"><b>Locate a site </b></font><a href="#" onClick="MM_openBrWindow('../html%20help/search/sitesearch.htm','test','scrollbars=yes,resizable=yes,width=360,height=350')"><img src="../buttons/help01.gif" width="35" height="32" border="0"></a>
<br>
<br>
<font face="Arial, Helvetica, sans-serif"><b>Please enter / select your search
criteria below. </b></font>
<form name="myForm" method="post" action="testtwo.cfm" onSubmit="return checkFields()" >
<table width="433" border="0" height="179">
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>ASC: </b></font></div>
</td>
<td width="281">
<select name="asc_order_cd" >
<option value="allasc" onFocus="document.myForm.asc_order_cd.selectedIndex >= 1;" size=10 selected>(All
Asc)
<cfoutput query="order">
<option value="#code# ">#code# | #description#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Site Number:
</b></font></div>
</td>
<td width="281">
<input type="text" name="site_number" value="" onFocus="document.myForm.site_number.value='';" size=10>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Surveyor
One: </b></font></div>
</td>
<td width="281">
<select name="surveyorone" >
<option value="allsurveyor" onFocus="document.myForm.surveyorone.selectedIndex >= 1;" size=10 selected>(All
Surveyors)
<cfoutput query="sureone">
<option value="#surveyor_code#">#surveyor_code# | #surveyor_last_name#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Project
Code: </b></font></div>
</td>
<td width="281">
<select name="proj_code">
<option value="allprojects" onFocus="document.submitform.proj_code.selectedIndex >= 1;" size=10 selected>(All
Projects)
<cfoutput query="projectcode">
<option value="#project_code# ">#project_code# | #project_title#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Factual
Key: </b></font></div>
</td>
<td width="281">
<select name="factual_key" >
<option value="allfactualkey" onFocus="document.myForm.factual_key.selectedIndex >= 1;" size=10 selected>(All
Factual Keys)
<cfoutput query="factualkey">
<option value="#code#">#code# |#description#
</cfoutput>
</select>
</td>
</tr>
</table>
<table width="435" border="0" height="106">
<tr>
<td width="108">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Easting:
</b></font></div>
</td>
<td width="165">
<input type="text" name="e1" value="" onFocus="document.myForm.e1.value='';" size=10 maxlength="6">
between </td>
<td width="148">
<input type="text" name="e2" size=10" maxlength="6">
</td>
</tr>
<tr>
<td width="108">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Northing:
</b></font></div>
</td>
<td width="165">
<input type="text" name="n1" value="" onFocus="document.myForm.n1.value='';" size=10 maxlength="7">
between</td>
<td width="148">
<input type="text" name="n2" size=10" maxlength="7">
</td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" value="Find a matching site" onClick="validate();return returnVal;" >
</p>
</form>
The error coming up is "init is not defined". Even thought it is defined within the body tag. The whole of the code is place below. The first section of code is to check that at least one field has been changed. This prevents the query from returning all the records in the table. This is working well. The second is where I need the number validation working but the the script is says "init is not defined" I wondering is it possible to have two function validation in one form. For example Onsumbit for one function which to check for the required field and for the second Onclick to validate as a number with a maximum number of characters.
****
code
**
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkFields() {
asc_order_cd = document.myForm.asc_order_cd.selectedIndex >= 1;
site_number = document.myForm.site_number.value;
surveyorone = document.myForm.surveyorone.selectedIndex >= 1;
proj_code = document.myForm.proj_code.selectedIndex >= 1;
factual_key = document.myForm.factual_key.selectedIndex >= 1;
e1 = document.myForm.e1.value;
n1 = document.myForm.n1.value;
if ((asc_order_cd == "" && (site_number == "" && (surveyorone == ""&&(proj_code == ""&&(factual_key == "" && (e1 == ""&&(n1 == "") {
alert("Please select or enter either a ASC, Site Number, Surveyorone, Project Code, Factual Key , Easting, Northing."
return false;
}
else return true;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript" src="../buttons/validation.js">
<!--
function init() {
define('e1', 'num', 'e1', 6);
define('e2', 'num', 'e2', 6);
define('n1', 'num','n1', 7);
define('n2', 'num', 'n2', 7);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" background="../buttons/Texture_brown_051.jpg" OnLoad="init()">
<font face="Arial, Helvetica, sans-serif" size="5"><b>Locate a site </b></font><a href="#" onClick="MM_openBrWindow('../html%20help/search/sitesearch.htm','test','scrollbars=yes,resizable=yes,width=360,height=350')"><img src="../buttons/help01.gif" width="35" height="32" border="0"></a>
<br>
<br>
<font face="Arial, Helvetica, sans-serif"><b>Please enter / select your search
criteria below. </b></font>
<form name="myForm" method="post" action="testtwo.cfm" onSubmit="return checkFields()" >
<table width="433" border="0" height="179">
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>ASC: </b></font></div>
</td>
<td width="281">
<select name="asc_order_cd" >
<option value="allasc" onFocus="document.myForm.asc_order_cd.selectedIndex >= 1;" size=10 selected>(All
Asc)
<cfoutput query="order">
<option value="#code# ">#code# | #description#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Site Number:
</b></font></div>
</td>
<td width="281">
<input type="text" name="site_number" value="" onFocus="document.myForm.site_number.value='';" size=10>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Surveyor
One: </b></font></div>
</td>
<td width="281">
<select name="surveyorone" >
<option value="allsurveyor" onFocus="document.myForm.surveyorone.selectedIndex >= 1;" size=10 selected>(All
Surveyors)
<cfoutput query="sureone">
<option value="#surveyor_code#">#surveyor_code# | #surveyor_last_name#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Project
Code: </b></font></div>
</td>
<td width="281">
<select name="proj_code">
<option value="allprojects" onFocus="document.submitform.proj_code.selectedIndex >= 1;" size=10 selected>(All
Projects)
<cfoutput query="projectcode">
<option value="#project_code# ">#project_code# | #project_title#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td width="142">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Factual
Key: </b></font></div>
</td>
<td width="281">
<select name="factual_key" >
<option value="allfactualkey" onFocus="document.myForm.factual_key.selectedIndex >= 1;" size=10 selected>(All
Factual Keys)
<cfoutput query="factualkey">
<option value="#code#">#code# |#description#
</cfoutput>
</select>
</td>
</tr>
</table>
<table width="435" border="0" height="106">
<tr>
<td width="108">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Easting:
</b></font></div>
</td>
<td width="165">
<input type="text" name="e1" value="" onFocus="document.myForm.e1.value='';" size=10 maxlength="6">
between </td>
<td width="148">
<input type="text" name="e2" size=10" maxlength="6">
</td>
</tr>
<tr>
<td width="108">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>Northing:
</b></font></div>
</td>
<td width="165">
<input type="text" name="n1" value="" onFocus="document.myForm.n1.value='';" size=10 maxlength="7">
between</td>
<td width="148">
<input type="text" name="n2" size=10" maxlength="7">
</td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" value="Find a matching site" onClick="validate();return returnVal;" >
</p>
</form>