473,698 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ 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...trie d 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("txtFirst Name")) and _
Not IsEmpty(Request .Form("txtLastN ame")) 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("txtFirstN ame")%>&nbsp<%= Request.Form("t xtLastName")%>
for your information.
Have a nice day!
</body>
</html>

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

<html>
<head>
<script language="javas cript">

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

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

//if(document.all .txtFirstName.v alue == "" ||
document.all.tx tLastName.value == "")
if(trim(documen t.forms("frmInf o").elements("t xtFirstName").v alue) ==
"" || trim(document.f orms("frmInfo") .elements("txtL astName").value ) ==
"")
//document.swOrde r.elements[0].value
//if(trim(documen t.frmInfo.eleme nts[0].value == "" ||
trim(document.f rmInfo.elements[1].value) == "")
{
document.frmInf o.reset();
alert("Please enter both first and last names.");
return false;
}
document.frmInf o.submit();
return true;
}
</script>
<title>Thank You</title>
</head>
<body>
Please fill out this form:
<form name="frmInfo" action="AllCont rols.asp" method="post">

First Name: <input type="text" name="txtFirstN ame"><br>
Last Name: <input type="text" name="txtLastNa me"><br>
<input type="Button" value="Submit User Info" onclick="valida te()">
<input type="reset">

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

Jul 23 '05 #1
4 1687
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="javas cript">

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

<script type="text/javascript">

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

<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.val ue == "")

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.mozill a.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(documen t.forms("frmInf o").elements("t xtFirstName").v alue) ==
"" || trim(document.f orms("frmInfo") .elements("txtL astName").value ) ==
"")
?
Thank you.

Jul 23 '05 #4
Got it!
if(trim(documen t.frmInfo.txtFi rstName.value) == "" ||
trim(document.f rmInfo.txtLastN ame.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
4512
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 sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below is the code; this clever algorithm is painstakingly explained at the site above.)
4
2762
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 javascript code. Note that in the actual file, I've surrounded the variable '#cookie.cookiename#' with CFOUTPUT tags: document.write('<input type="Hidden" name="affiliate" value="#cookie.cookiename#">'); When I load the document in Netscape 7, I...
15
7288
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 same problem. Internet Explorer 6 and Opera 7 have no problems with it. <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <script>document.write (window.history.length);</script>
2
1886
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 HAS THE SCROLLBAR (does not if the right side does not have the scrollbar on). Also, if you move around each "this is a test" line, the onmouseout event fires. How odd? Fortunately, I can have logic to handle this. The big problem is why...
18
1551
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 variables manually, but Im not sure whats broken. I assume that the images aren't being freed when they are replaced. Is there a workaround/solution to this? I've read some old postings about this in 4.x browsers, but I never saw a solution, and...
7
2322
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 frames, where the two lower ones are within a Frameset within the master Frameset: 1111111111111111111
7
1847
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" these problems - I'm more interested in isolating them, .i.e. finding a "complete" list of issues. Here's my list of serious issues found so far. By serious, I mean functionality that fails, as opposed to much less serious (albeit annoying) display...
5
2580
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 is the code for this. the onclick event calls a javascript function which I put an alert in the firt line to tell me if its working. It does work in IE. Any ideas on how to get netcrap... oops, I'm sorry, netscape to fire the onclick event? ...
2
19578
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> </form> <span id="txtValue"></span> <script language='javascript'>
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
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 we have to send another system
2
2331
muto222
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.