Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript firefox problem

Dave Blair
Guest
 
Posts: n/a
#1: Jul 23 '05
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


Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Javascript firefox problem




Dave Blair wrote:

[color=blue]
> 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[/color]

[color=blue]
> 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.[/color]

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.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Søren Munk Skrøder
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Javascript firefox problem


Dave Blair wrote:
[color=blue]
> 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
>[/color]

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
Dave Blair
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Javascript firefox problem


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!

On Mon, 28 Jun 2004 14:45:06 +0200,
=?ISO-8859-1?Q?S=F8ren_Munk_Skr=F8der?= <a@b.com> wrote:
[color=blue]
>Dave Blair wrote:
>[color=green]
>> 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
>>[/color]
>
>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[/color]

Mark Preston
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Javascript firefox problem


Dave Blair wrote:
[color=blue]
> 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.[/color]
[snip][color=blue]
>
> Function checkempty(ByVal FieldValue, ByVal message)
> If FieldValue = "" then
> MsgBox message, 8, Header
> checkempty = False
> else
> checkempty = true
> End if
> end function
>[/color]
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.
Closed Thread