Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript validation not working in Nestcape

Status
Not open for further replies.

philrm

MIS
Jun 1, 1999
58
0
0
AU
*** The following javascript is producing this sort of error in Netscape "myForm is not defined", this works in Internet Explorer. Could somebody helpful me as soon as possible.Thank's
<HTML>
<HEAD>
<TITLE></TITLE>


<script language=&quot;JavaScript&quot;>

<!--
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); return x;
}

function MM_validatetheForm() { //v3.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validatetheForm.arguments, depth_from=parseFloat(myForm.depth_from.value), depth_to=parseFloat(myForm.depth_to.value);
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!=&quot;&quot;) {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inDepth') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (depth_to<depth_from || max<depth_to) errors+='- '+nm+' must be greater than '+depth_from+'.\n';
} if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num>min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

function MM_validateForm() { //v3.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!=&quot;&quot;) {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->

</script>
</HEAD>
<BODY BGCOLOR=&quot;#FFFFFF&quot; vlink=&quot;#0000FF&quot; alink=&quot;#FF3333&quot; background=&quot;../../buttons/83.jpg&quot;>
<table width=&quot;51%&quot; border=&quot;0&quot; height=&quot;30&quot;>
<tr>
<td>
<div align=&quot;right&quot;>
<h2>&nbsp;</h2>
</div>
</td>
</tr>
</table>
<table width=1000 height=&quot;100&quot; border=&quot;1&quot;>
<tr>
<td width=&quot;7%&quot; >&nbsp;</td>
<td colspan=&quot;27&quot;>
<p><font size=&quot;4&quot;>Viewing Table Only - Result for the entered data below.</font></p>
</td>
</tr>
<tr>
<td width=&quot;7%&quot; height=&quot;24&quot;>
<div align=&quot;center&quot;></div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Profile ID</div>
</td>
<td width=&quot;2%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Site ID</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Soil Horizon</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Depth From</div>
</td>
<td width=&quot;2%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Depth To</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Moist Colour</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Dry Colour</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Bleach Type</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Soil Texture</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Q1</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Q2</div>
</td>
<td width=&quot;6%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Distinct</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Shape</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Field PH value</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>PH Depth</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>PH Method</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Sub Colour 1</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Sub Colour 2</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Strength</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Stickiness</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Plasticity</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Water Status</div>
</td>
<td width=&quot;3%&quot; height=&quot;24&quot;>
<div align=&quot;center&quot;>Carbonate</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Repellence</div>
</td>
<td width=&quot;5%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Permeability</div>
</td>
<td width=&quot;4%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Emerson</div>
</td>
<td width=&quot;3%&quot; height=&quot;8&quot;>
<div align=&quot;center&quot;>Horizon Comments</div>
</td>
</tr>

</table>
<h2>Enter New Profile</h2>
<FORM ACTION=&quot;formthree.cfm?EnterNewProfile=Yes&quot; name=&quot;myForm&quot; METHOD=POST>
<pre><a href=&quot;../login.cfm&quot;>Logout</a>: Yogendran Nadarajah
<p>site ID: 2737 <input type=&quot;hidden&quot; name=&quot;site_id&quot; value=&quot;2737&quot;></pre>
<table width=&quot;91%&quot; border=&quot;0&quot; height=&quot;61&quot;>
</table>
<table width=&quot;91%&quot; border=&quot;1&quot;>
<tr>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;right&quot;><b>Soil Horizon</b></div>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<input type=&quot;text&quot; name=&quot;horizon_name&quot;>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;right&quot;><b>Soil Texture</b></div>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;left&quot;>
<select name=&quot;texture_cd&quot;>

<option value=&quot;&quot;>
| </option>

<option value=&quot;S&quot;>S
| Sand</option>

<option value=&quot;LS&quot;>LS
| Loamy sand</option>

<option value=&quot;CS&quot;>CS
| Clayey sand</option>

<option value=&quot;SL&quot;>SL
| Sandy loam</option>

<option value=&quot;FSL&quot;>FSL
| Fine sandy loam *</option>

<option value=&quot;LSCL&quot;>LSCL
| Light sandy clay loam**</option>

<option value=&quot;L&quot;>L
| Loam</option>

<option value=&quot;LFS&quot;>LFS
| Loam fine sandy *</option>

<option value=&quot;ZL&quot;>ZL
| Silty loam</option>

<option value=&quot;SCL&quot;>SCL
| Sandy clay loam</option>

<option value=&quot;CL&quot;>CL
| Clay loam</option>

<option value=&quot;CLS&quot;>CLS
| Clay loam, sandy</option>

<option value=&quot;ZCL&quot;>ZCL
| Silty clay loam</option>

<option value=&quot;LC&quot;>LC
| Light clay</option>

<option value=&quot;LMC&quot;>LMC
| Light medium clay</option>

<option value=&quot;MC&quot;>MC
| Medium clay</option>

<option value=&quot;MHC&quot;>MHC
| Medium heavy clay</option>

<option value=&quot;HC&quot;>HC
| Heavy clay</option>

<option value=&quot;C&quot;>C
| Clay (unspecified) *</option>

</select>
</div>
</td>
</tr>
<tr>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;right&quot;><b>Depth From</b></div>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<input type=&quot;text&quot; name=&quot;depth_from&quot;>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;right&quot;><b>Qualifier(Q1) </b></div>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<select name=&quot;texture_q1_cd&quot;>

<option value=&quot;&quot;>|</option>

<option value=&quot;F&quot;>F|Fine Sandy</option>

<option value=&quot;S&quot;>S|Medium Sandy</option>

<option value=&quot;K&quot;>K|Coarse Sandy</option>

<option value=&quot;Z&quot;>Z|Silty</option>

</select>
</td>
</tr>
<tr>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<div align=&quot;right&quot;><b>Depth To</b></div>
</td>
<td width=&quot;2%&quot; height=&quot;4&quot;>
<input type=&quot;text&quot; name=&quot;depth_to&quot; onBlur=&quot;MM_validatetheForm('depth_to','','NinDepth0:10000');return document.MM_returnValue&quot;>
</td>
 
Hi

It looks as if you've hit a classic difference between the Document Object Models (DOMs) in IE and Netscape.

I think you need to modify your code slightly in MM_validateForm to run different assignment code depending on browser - e.g.

if ( navigator.appName.lastIndexOf(&quot;Netscape&quot;) != -1 ) // i.e. using Netscape
{
depth_from=parseFloat(document.myForm.depth_from.value),
depth_to=parseFloat(document.myForm.depth_to.value);
} else //using IE
{
depth_from=parseFloat(myForm.depth_from.value),
depth_to=parseFloat(myForm.depth_to.value);
}


Hope this helps!

Regards
Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top