Solved

problem in javascript

Posted on 2000-03-30
2
1,068 Views
Last Modified: 2012-06-27
Hey all,
may be somebody can help me with this..
Just have 3 textboxes...


<FORM name='myform' action='#'>
 <INPUT type='text' name='month' size='10' maxlength='10'>
 <INPUT type='text' name='day' size='10' maxlength='10' > 
 <INPUT type='text' name='year' size='10' maxlength='10'>
</form>

I am trying to find a way to know which element has my focus --  in javascript..

is there anything like   isfocus   in javascript...???

help me with this pls..

regards
0
Comment
Question by:narrav
  • 2
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 2670987
<SCRIPT language='javascript'>
 var isfocused = null;
</script>


<FORM name='myform' action='#'>
 <INPUT type='text' name='month' size='10' maxlength='10' onFocus='isfocused=this;'>
 <INPUT type='text' name='day' size='10' maxlength='10'  onFocus='isfocused=this;'>
 <INPUT type='text' name='year' size='10' maxlength='10'  onFocus='isfocused=this;'>
</form>


now at any time you wish to know which element has focus, simply do this:

if ( isfocused )
  alert( isfocused.name );
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 80 total points
ID: 2670997
... ok, a bad example maybe because as soon as you do the "alert" above, the focus is removed from the element and put on the alert box instead.  :>0   But the idea is the same, the "isfocused" variable will point to the form element that most recently received focus.  :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now