setfocus after alert in javascript

A

amy

I have a text box, after user input the value, a validate function
trigered. if the value is invalid, alert display, and also set focus
back to this control.

The alert displays, but when the click the 'OK' in the alert, the set
focus to this field does not work.

see the code bellow:

if (run!="" && IsNumber(run)==false && decimalinputvalid(run,2)==0 )
{
alert('wow');

//first try doen not working
(setFocus) ? document.papercaltbl.printorder.focus() : ""

//seconde try doen not working
this.getField("printorder").setFocus();

//third try doen not working
document.getElementById("printorder").focus();
}

Please give some advise. Thanks in advance.
 
D

DJ WIce

Are you sure that
setFocus
is global?

the
this
will probable not refer to what you want.

I assume the focus error comes in Mozilla/Netscape?
Maybe you should put an url or or more info into your question?

Wouter

: I have a text box, after user input the value, a validate function
: trigered. if the value is invalid, alert display, and also set focus
: back to this control.
:
: The alert displays, but when the click the 'OK' in the alert, the set
: focus to this field does not work.
:
: see the code bellow:
:
: if (run!="" && IsNumber(run)==false && decimalinputvalid(run,2)==0 )
: {
: alert('wow');
:
: //first try doen not working
: (setFocus) ? document.papercaltbl.printorder.focus() : ""
:
: //seconde try doen not working
: this.getField("printorder").setFocus();
:
: //third try doen not working
: document.getElementById("printorder").focus();
: }
:
: Please give some advise. Thanks in advance.
 

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,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top