473,508 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setfocus after alert in javascript

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.
Jul 20 '05 #1
1 3243
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

"amy" <aj***@elario.com> wrote in message
news:7f**************************@posting.google.c om...
: 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.
Jul 20 '05 #2

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

Similar topics

1
2030
by: amy | last post by:
I have a text box, once the user input the value in, I do a validate to the input, if it's invalid, then do a alert and set focus to this control. The alert displays, but the set focus doesn't...
2
16847
by: schieco | last post by:
The following code always prints the debug lines inside the conditional if statement before and after the alert statement when the session has timed out, but the alert and redirect only appear/work...
4
9666
by: Mad Scientist Jr | last post by:
i am trying to set focus to a specific control depending on the outcome of a validator control and it is not working. none of these methods are working to setfocus: 1....
6
1950
by: CoTConnie | last post by:
I'm trying to setfocus on a textbox after an error conditions, but the compile insists that 'textbox.setfocus' isn't a valid command. I'm using all the web page default setting, but am creating it...
4
1389
by: jonefer | last post by:
They couldn't have done away with how to setfocus to a control... like in response to an incorrect value input to a textbox... If Not IsDate(txt_DOB) then txt_DOB.SetFocus End If How do I...
0
1511
by: MrsLeigh | last post by:
I have a datagrid on a web page. In the footer there is a field that should be recieve the focus, either at the start or after a button is clicked to insert the row that is being added in the...
3
9619
by: umdsasha | last post by:
So, basically, I need to detect whether an alert window was thrown. I can't find where it's thrown from but I need to disable a button only if there were no alert windows thrown. Any ideas? ...
4
4009
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
24
8179
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
0
7135
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...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
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...
1
7067
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...
0
3215
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.