473,666 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onChange event and focus()

Am I right in assuming that you can NOT set focus() back to a field in
its onChange event? Is there another way - I have validation that I
would like to set the focus back to the invalid field onChange?

Eg:
<input type=text" name="tstfld" onChange="windo w.alert('Change d!');
this.focus()">
Jul 23 '05 #1
1 3057
SimonFx wrote:
Am I right in assuming that you can NOT set focus() back to a field in
its onChange event? Is there another way - I have validation that I
would like to set the focus back to the invalid field onChange?

Eg:
<input type=text" name="tstfld" onChange="windo w.alert('Change d!');
this.focus()">


I think I have solved this using setTimeout, but it feels dirty.

function validateField (f){
// blah blah field is bad so:
setTimeout ('document.' + f.form.name + '.' + f.name + '.focus()',100) ;
setTimeout ('window.alert (\'Invalid entry.\')', 100);
}

</SCRIPT>
</HEAD>
<BODY>

<FORM NAME="myForm">
<input type="text" name="myFld" onChange="valid ateField(this); ">
</FORM>
Jul 23 '05 #2

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

Similar topics

2
12141
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time , suppose we put the same value in the text box then no event is fired. If we put some other value then it became fired... It wouldn't fire if we put the same value... I don't want to use onBlur etc... Isthere any solution with onChange Event...?
2
3120
by: DonD | last post by:
I have a form that allows a user to upload a file. When they select a file (onChange), I call a JS function that analyzes the filename for specific keywords and then populates a multiple select box with the keywords. The problem is, IE for Mac doesn't do the onChange properly. In all other browsers, as soon as I select the file, the onChange fires and the filename gets analyzed, etc. In IE for Mac, I have to click away from the file...
2
7765
by: crjunk | last post by:
I have a javascript that will output a message telling the user that changes were made. It halfway works. If the user enters in a number, the TextChanged function executes and displays the "Changes Made" message, but if the user deletes a number by using the BACKSPACE key or the DELETE key on the keyboard, the function does not run. Am I using the wrong event handler? function TextChanged(){...
3
3971
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having a couple of problems, which I'll try to describe. But this e-mail will only reproduce one of them, in a "short" example. What I'm generally doing is having each form entry contained in a div, which as a label, an input with some event handlers,...
10
4928
by: david.bercot | last post by:
Hi, I have a big problem with a simple event : onchange !!! If I write this page : <html> <body> <form id="vu"> <input id="var01" name="var01" size="5" onchange="return false;"/> </form> </body>
2
3922
by: pendragn | last post by:
I've come across a problem I just can't solve. I have an text element I need to evaluate on change. All I need to do is open a confirm dialog asking if they'd like to save the change, if yes, I save the change and move on, if no the textbox needs to revert to it's original value. All of this works wonderfully as long as the browser window keeps focus durring the onchange event. However if the window looses focus triggering the onchange...
2
2066
by: William Cole | last post by:
Here is my issue I have two text fields (Field A, Field B). I want Field B to be updated when Field A is changed. The problem is Field A is being changed through JavaScript so an onChange event is not fired. Is there any way to make this work without having to change the code that changes Field A? Thanks, William
7
20859
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box is clicked, or "Enter" is hit in the attached text box. I can get the value of the element. But in Netscape 7, onChange doesn't fire until focus leaves the element. When you double-click a file name or click "open" in the Open box, the...
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8363
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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 we have to send another system
2
1778
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.