Javascript firefox problem

D

Dave Blair

Hi,
I have a problem with our intranet, we are planning to install Firefox
instead of Internet Explorer onto some new PCs.

However, we can't get the following JavaScript to work in Firefox and
similar code is used in lots of the intranet stuff.
The code should bring up a message box with a warning and not allow
the user to continue unless they have filled in the entry in an html
form (the form is called 'myauthor').


if (checkempty(Document.myauthor.Candidate.Value,"You have left the
Candidate field empty."))= false then validation=false


If validation= True then
myauthor_OnSubmit = True
else
myauthor_OnSubmit = False
End if
End function


Function checkempty(ByVal FieldValue, ByVal message)
If FieldValue = "" then
MsgBox message, 8, Header
checkempty = False
else
checkempty = true
End if
end function

No errors or warnings appear in the firefox JavaScript console. The
page just accepts the form and continues as if the checking code
weren't there at all.

Thanks for any help,
Dave
 
M

Martin Honnen

Dave Blair wrote:

However, we can't get the following JavaScript to work in Firefox and
similar code is used in lots of the intranet stuff.
The code should bring up a message box with a warning and not allow

if (checkempty(Document.myauthor.Candidate.Value,"You have left the
Candidate field empty."))= false then validation=false


If validation= True then
myauthor_OnSubmit = True
else
myauthor_OnSubmit = False
End if
End function


Function checkempty(ByVal FieldValue, ByVal message)
If FieldValue = "" then
MsgBox message, 8, Header
checkempty = False
else
checkempty = true
End if
end function

No errors or warnings appear in the firefox JavaScript console. The
page just accepts the form and continues as if the checking code
weren't there at all.

That is not JavaScript but VBScript so there is no way FireFox or any
other browser besides IE/Win is going to run that code.
 
S

Søren Munk Skrøder

Dave said:
Hi,
I have a problem with our intranet, we are planning to install Firefox
instead of Internet Explorer onto some new PCs.

However, we can't get the following JavaScript to work in Firefox and
similar code is used in lots of the intranet stuff.
The code should bring up a message box with a warning and not allow
the user to continue unless they have filled in the entry in an html
form (the form is called 'myauthor').


if (checkempty(Document.myauthor.Candidate.Value,"You have left the
Candidate field empty."))= false then validation=false


If validation= True then
myauthor_OnSubmit = True
else
myauthor_OnSubmit = False
End if
End function


Function checkempty(ByVal FieldValue, ByVal message)
If FieldValue = "" then
MsgBox message, 8, Header
checkempty = False
else
checkempty = true
End if
end function

No errors or warnings appear in the firefox JavaScript console. The
page just accepts the form and continues as if the checking code
weren't there at all.

Thanks for any help,
Dave

Hmm ... perhaps it's because most of the code, you've written isn't
Javascript - but rather VBScript which is also supported in IE

i've taken the liberty to rewrite it (sort of) in javascript...

function checkEmpty( value, errMessage ) {
if(value=="") {
Alert( errMessage );
return false;
} else {
return true;
}
}


if( checkEmpty( document.forms['myauthor'].candidate.value, "You have
left the Candidate field empty..." ) ) {
/* validation ok - submit the form */
document.forms['myauthor'].submit();
} else {
/* don't do anything - vaidation failed */
return false;
}

/Søren Munk Skrøder
Odense, Denmark
soeren at skroeder dot dk
 
D

Dave Blair

I'm an idiot!!

I knew it was VBscript, but had just finished with another problem
that was Javascript (a menu, which is now working). And somehow my
brain hadn't woken up and...........monday morning.....and......

Anyway, thanks for the replies and the re-write!

Dave said:
Hi,
I have a problem with our intranet, we are planning to install Firefox
instead of Internet Explorer onto some new PCs.

However, we can't get the following JavaScript to work in Firefox and
similar code is used in lots of the intranet stuff.
The code should bring up a message box with a warning and not allow
the user to continue unless they have filled in the entry in an html
form (the form is called 'myauthor').


if (checkempty(Document.myauthor.Candidate.Value,"You have left the
Candidate field empty."))= false then validation=false


If validation= True then
myauthor_OnSubmit = True
else
myauthor_OnSubmit = False
End if
End function


Function checkempty(ByVal FieldValue, ByVal message)
If FieldValue = "" then
MsgBox message, 8, Header
checkempty = False
else
checkempty = true
End if
end function

No errors or warnings appear in the firefox JavaScript console. The
page just accepts the form and continues as if the checking code
weren't there at all.

Thanks for any help,
Dave

Hmm ... perhaps it's because most of the code, you've written isn't
Javascript - but rather VBScript which is also supported in IE

i've taken the liberty to rewrite it (sort of) in javascript...

function checkEmpty( value, errMessage ) {
if(value=="") {
Alert( errMessage );
return false;
} else {
return true;
}
}


if( checkEmpty( document.forms['myauthor'].candidate.value, "You have
left the Candidate field empty..." ) ) {
/* validation ok - submit the form */
document.forms['myauthor'].submit();
} else {
/* don't do anything - vaidation failed */
return false;
}

/Søren Munk Skrøder
Odense, Denmark
soeren at skroeder dot dk
 
M

Mark Preston

Dave said:
Hi,
I have a problem with our intranet, we are planning to install Firefox
instead of Internet Explorer onto some new PCs.

However, we can't get the following JavaScript to work in Firefox and
similar code is used in lots of the intranet stuff. [snip]

Function checkempty(ByVal FieldValue, ByVal message)
If FieldValue = "" then
MsgBox message, 8, Header
checkempty = False
else
checkempty = true
End if
end function
That code (above) is VBScript, not JavaScript or ECMAScript, so it has
no chance on anything except Microsoft-only browsers written to work
with Micrososft-only code. In other words - it will never run on Firefox
OR on any non-Wondows system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top