473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Checking for focus

Hello,
is there a function with which I can find out if a form element has the
focus?
Something like:

function ReactIfFocus()
{
for(var i=0; i<10; i++)
if( HasFocus(document.forms[0].elements[i])
makeSomething();
}

I need the function to move the focus to the next field.

Thanks
Christoph
Jul 23 '05 #1
3 2847


Christoph Weber wrote:
is there a function with which I can find out if a form element has the
focus?
Something like:

function ReactIfFocus()
{
for(var i=0; i<10; i++)
if( HasFocus(document.forms[0].elements[i])
makeSomething();
}

I need the function to move the focus to the next field.


There are event handlers onfocus and onblur that let you react to a
change of focus.
IE also has
if (document.activeElement == document.forms[0].elements[i])
see
http://msdn.microsoft.com/library/de...iveelement.asp

--

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

Jul 23 '05 #2
Danke !!
So geht es.
Jul 23 '05 #3
"Christoph Weber" <ch*************@im-achental.de> wrote in message news:<2g**********@uni-berlin.de>...
Hello,
is there a function with which I can find out if a form element has the
focus?
Something like:

function ReactIfFocus()
{
for(var i=0; i<10; i++)
if( HasFocus(document.forms[0].elements[i])
makeSomething();
}

I need the function to move the focus to the next field.

Thanks
Christoph

I did some quick Googling, and couldn't find anything like that.
What are you trying to do? The only suggestion I found is to
keep track of it or fire the desired function on the onfocus event.

Shawn
Jul 23 '05 #4

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

Similar topics

2
by: Philip D Heady | last post by:
Hi, I'm validating a simple form for input via post ($PHP_SELF). Near the end I check for username and password. I'm using simple if, elseif, else statements. I require them to enter password...
10
by: Samir | last post by:
Say I have 4 forms, all four have different numbers of text boxes. is there a script that I can use to check to make sure everything on the form is not blank?
4
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each...
1
by: tdmailbox | last post by:
Is there a vb command that can tell me if I have focus in the child or parent form? Basicly I have a search macro that needs me to have focus to any field in the parent form. If my focus is set...
0
by: Eric Hohnbaum | last post by:
I'm usng the WinForms DataGrid control and want to validate the phone fields and put the focus back if an error ocurrs. I have a Leave message handler attached to the TextBox of the phone number...
6
by: JohnnyW | last post by:
Hello, I have I simple question that is not clear for me. So, I have a input field (text field) in my html page. User should give input as a string like following 12 345 678,0 If user gives...
1
by: roN | last post by:
Hi, I'm getting desperate, I just wanna check if mandatory fields are filled with text on http://paykiosks.net/contact_new.htm but it somehow just wouldn't work. :( s mall piece looks like: if...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
1
by: Newcomsas | last post by:
Hello. I'm trying to solve a little problem with an uppercase function. It looks like this: function uppercase() { key = window.event.keyCode; if ((key 0x60) && (key < 0x7B))...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.