472,783 Members | 900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

DW function, Firefox works, IE doesn't.

I would like to ask you the following:

I use Macromedia Dreamweaver as an editor for HTML and Js.

It also writes some js functions to simply validate forms.

I always used it with no bugs.

Till now. This is the problem (and the page):

================================================== =========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>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[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
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 (isNaN(val)) 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>
<form name="formA">
<input type="text" name="pippo">
<input type="text" name="email">
<input name="A" type="submit"
onClick="MM_validateForm('pippo','','R','email','' ,'RisEmail');return
document.MM_returnValue" value="Invia">
</form>

<form name="formB">
<input type="hidden" name="pippo">
<input type="hidden" name="email">
</form>

</body>
</html>

================================================== =========================

My target is to validate "pippo" to have it not empty and "email" not
empty but also a valid email.

Dreamweaver wrote these 2 functions to do this and added onClick event
to button this way.

The only new thing I did is to write an hidden form with same fields
names because I have to do this before posting data.

I tried this code in Firefox and it works fine.

I tried this in IE and it says: "'val' is null or it is not an object".

What do you think about it?

Any help much appreciated.

Regards.

--
Fabri
(Incredibile come si tenda a credere di piu` a Rossi. (cit.))
Jul 23 '05 #1
2 2097
Fabri <no@sp.am> wrote in message news:<31*************@individual.net>...
I would like to ask you the following:

I use Macromedia Dreamweaver as an editor for HTML and Js.

It also writes some js functions to simply validate forms.

I always used it with no bugs.

Till now. This is the problem (and the page):

================================================== =========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>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[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
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 (isNaN(val)) 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>
<form name="formA">
<input type="text" name="pippo">
<input type="text" name="email">
<input name="A" type="submit"
onClick="MM_validateForm('pippo','','R','email','' ,'RisEmail');return
document.MM_returnValue" value="Invia">
</form>

<form name="formB">
<input type="hidden" name="pippo">
<input type="hidden" name="email">
</form>

</body>
</html>

================================================== =========================

My target is to validate "pippo" to have it not empty and "email" not
empty but also a valid email.

Dreamweaver wrote these 2 functions to do this and added onClick event
to button this way.

The only new thing I did is to write an hidden form with same fields
names because I have to do this before posting data.

I tried this code in Firefox and it works fine.

I tried this in IE and it says: "'val' is null or it is not an object".

What do you think about it?

Any help much appreciated.

Regards.


Well...you've got two pippos now so, you're up the creek. ;)

That MickeyMouse_findObj() routine isn't very good with same-named
form elements, which IE puts in an array (inside the document.all[]
array) so it can store pointers to both. Couldn't figure out any way
to pass that reference - pippo[0] - as a string argument, so the best
fix is probably to lose that function completely, and change this
line:

val=MM_findObj(args[i]);

....to

val=document.getElementById(args[i]);

Then:

<form name="formA">
<input id="pippo1" type="text" name="pippo" value="">
<input id="email1" type="text" name="email" value="">
<input name="A" type="submit"
onClick="MM_validateForm('pippo1','','R','email1', '','RisEmail');return
document.MM_returnValue" value="Invia">
</form>

<form name="formB">
<input id="pippo2" type="hidden" name="pippo">
<input id="email2" type="hidden" name="email">
</form>

....and it should work. Totally useless (catch-all) code for simple
validations, though.

Always set value="" for form elements, some browsers will do it it for
you otherwise.
Jul 23 '05 #2
RobB wrote:
val=MM_findObj(args[i]);

...to

val=document.getElementById(args[i]);
[CUT]
...and it should work. Totally useless (catch-all) code for simple
validations, though.

Rob...simply perfect :-)

Thank you very much.

--
Fabri
(Incredibile come si tenda a credere di piu` a Rossi. (cit.))
Jul 23 '05 #3

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

Similar topics

4
by: nec | last post by:
Hi, I'm having trouble calling a function thats located in a iFrame from the parent. Shortly, i can't figure out the location in DOM. In IE it works fine with a simple line of...
6
by: Cliff R. | last post by:
Hi, I use a handy little Javascript Flash detection script on a number of sites (copied below). Usually works great, but I just started trying Firefox and it's not working. A few browsers are...
6
by: rwsims | last post by:
This works in firefox, not at all in ie6. I'm not getting any errors, but only the doalert() function works, not the click() function. I'm sure there's something obvious, but I'm just not seeing...
1
by: Hugo Flores | last post by:
Hello I have this code in actionscript that calls javascript: actionscript: zoom_in = function () { var tw1:Tween = new Tween(mc_1, "_width", Regular.easeOut, mc_1._width, 0, 1, false);...
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
7
by: Darko | last post by:
Hello, I have this particular problem with eval() when using Microsoft Internet Explorer, when trying to define an event handler. This is the code: function BigObject() { this.items = new...
6
by: yawnmoth | last post by:
I'm trying to write a so-called bookmarklet for a specific web app and am having some difficulty. One of the names of a specific forms inputs is submit. As such, doing...
7
by: Carlos Mendonça | last post by:
Has anyone managed to get ClickOnce to work with Firefox? It seems to me that it still has the same issues VS 2K5 had. I appreciate any comments or tips.
7
by: Andrew Poulos | last post by:
Say I have this foo = function() { // blah }; bar = fuction(fnName) { /* If fnName equalled "foo" * How do I test that foo, as a function, * exists and then, if it exists, call it?
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.