473,471 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IE and Netscape Difference: ASP/JavaScript Problem

Why won't Netscape do the intended in the following? IE is able to
render this page as intended. It is is a "self-posting" ASP form with a
JavaScript validation function: if the form fails the JavaScript
validation function, then the form should not post and an alert should
be issued as indicated below.

The *first* alert in the Validate function works in NS, but the rest of
the code does not and therefore I wonder about the way I am referencing
the controls...tried to experiment with this, as can be seen in the
rem'd out code. Tried to research in my books...

Thanks for any and all! Jules

---------------------------------------------------------------------------------------------------------------
<%Option Explicit%>

<%
'This is a self-posting form: the same form is used for both
'the request and response objects

If not IsEmpty(request.Form("txtFirstName")) and _
Not IsEmpty(Request.Form("txtLastName")) then
'the form has been filled out and a brief thank you is sent
%>
<html>
<head>
<title>Thank You</title>

</head>

<body>
Thank you
<br><%=Request.Form("txtFirstName")%>&nbsp<%=Reque st.Form("txtLastName")%>
for your information.
Have a nice day!
</body>
</html>

<%Else%>
<!--Form has not been filled out, so provide it!-->

<html>
<head>
<script language="javascript">

function trim(strField){
alert("trim");
return strField.replace(/^\s+/,'').replace(/\s+$/,'')
}

function validate()
{
alert("validate");

//if(document.all.txtFirstName.value == "" ||
document.all.txtLastName.value == "")
if(trim(document.forms("frmInfo").elements("txtFir stName").value) ==
"" || trim(document.forms("frmInfo").elements("txtLastNa me").value) ==
"")
//document.swOrder.elements[0].value
//if(trim(document.frmInfo.elements[0].value == "" ||
trim(document.frmInfo.elements[1].value) == "")
{
document.frmInfo.reset();
alert("Please enter both first and last names.");
return false;
}
document.frmInfo.submit();
return true;
}
</script>
<title>Thank You</title>
</head>
<body>
Please fill out this form:
<form name="frmInfo" action="AllControls.asp" method="post">

First Name: <input type="text" name="txtFirstName"><br>
Last Name: <input type="text" name="txtLastName"><br>
<input type="Button" value="Submit User Info" onclick="validate()">
<input type="reset">

</form>
</body>
</html>
<%End if %>

Jul 23 '05 #1
4 1672
JJ****@hotmail.com wrote:
<snip>
The *first* alert in the Validate function works in NS,
but the rest of the code does not and therefore I wonder
about the way I am referencing the controls... <snip>

Why wonder, Netscape/Gecko browsers provide very explicit error reports
in their javascript console?

<script language="javascript">

The language attribute is deprecated and the type attribute is required
in valid HTML 4. So:-

<script type="text/javascript">

<snip> document.all.txtLastName.value == "")
Only the very latest Mozilla/Gecko browsers support - document.all - so
that does not include any Netscape releases.
if(trim(document.forms("frmInfo").
The - document.forms - collection is (W3C) specified as an object not a
function. As such its members should be referenced using bracket
notation.
elements("txtFirstName").value) ==

<snip>

The - elements - collection of form elements is (W3C) specified as an
object not a function. As such its members should be referenced using
bracket notation.

Netscape browsers will not have made it past those two errors.

Richard.
Jul 23 '05 #2
Richard Cornford wrote:
JJ****@hotmail.com wrote: <snip>
document.all.txtLastName.value == "")

Only the very latest Mozilla/Gecko browsers support - document.all - so
that does not include any Netscape releases.


IMO, you should say "have limited support for". An informative
discussion on Mozilla/Geko support for document.all is here:

<URL:https://bugzilla.mozilla.org/show_bug.cgi?id=248549>

Mozilla/Geko's support for document.all seems limited to the
ability to create a reference to an element and that's it.
--
Rob
Jul 23 '05 #3
I tried the JavaScript Console before posting my initial question and
it returned no messages at all and so I posted my inquiry here. I tried
to change the <script> tag and the script still fails...if the control
references are incorrect, how do I correct them? I tried various ways
of using "bracket notation" as well before posting my first inquiry
(rem'd out code in original posting I believe) and did not get the
script to work. If this line is wrong, how is it to be changed to to
bracket notation so that it works in NS?
if(trim(document.forms("frmInfo").elements("txtFir stName").value) ==
"" || trim(document.forms("frmInfo").elements("txtLastNa me").value) ==
"")
?
Thank you.

Jul 23 '05 #4
Got it!
if(trim(document.frmInfo.txtFirstName.value) == "" ||
trim(document.frmInfo.txtLastName.value) == "")

This works in Netscape and IE.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some...
4
by: Yvan J. Gagnon | last post by:
I am encountering a strange problem in Netscape 7 with a CFM file I am trying to troubleshoot (the page is working fine in NS Communicator and IE). Below is a sample of the problematic line of...
15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
2
by: Kevin Ly | last post by:
Consider the test case below. The onmouseout event does NOT fire when my mouse/cusor is moved off the left side of the browser. It does if it is moved off the top, bottom, and the right side that...
18
by: Dennis | last post by:
It seems that garbage collection is somewhat flawed in Netscape as the following little script can bring a machine to its knees in about an hour when run on Netstcape 7.1. I've tried freeing the...
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
7
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
5
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below...
2
by: xhe | last post by:
I met a very headache problem in javascript, I think this might be difference between IE and NS / Safari. I have a text area <form> <textarea name='tex1' onkeyup='displayit();'></textarea>...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.