473,394 Members | 1,794 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,394 software developers and data experts.

focus

I apologize for another post about focus, but whatever I try just
doesn't seem to work. I appreciate any ideas that you could give me on
getting the focus back to the textbox after tabbing or clicking out.
Jason

function checkTime(timeVal) {
var hr, mn;
if (timeVal.length != 4)
{
alert("Time entered must be 4 characters: ex. 0130.");
document.setCond.elements['hwtime'].focus();
}

<INPUT TYPE="text" NAME="hwtime" ID="hwTime" SIZE=4 MAXLENGTH=4
VALUE="Time" onfocus='this.value="";'
onchange='checkTime(this.value);'>
Jul 20 '05 #1
3 3660
jkstinn wrote:
I apologize for another post about focus, but whatever I try just
doesn't seem to work. I appreciate any ideas that you could give me on
getting the focus back to the textbox after tabbing or clicking out.
Jason

function checkTime(timeVal) {
var hr, mn;
if (timeVal.length != 4)
{
alert("Time entered must be 4 characters: ex. 0130.");
document.setCond.elements['hwtime'].focus();
}

<INPUT TYPE="text" NAME="hwtime" ID="hwTime" SIZE=4 MAXLENGTH=4
VALUE="Time" onfocus='this.value="";'
onchange='checkTime(this.value);'>


Hi,

What is setCond?
Difficult to say without the complete code.

I am sure the following code works:
document.forms.yourformnamehere.hwtime.focus();

where you have to replace yourformnamehere by the name of the form this
element is in.

Please also check you are not accidentally using the same formname and
elementname twice.
Why are you using an ID and a name? (Just curious)
You could also try to remove the onfocus='this.value="";' and place that in
the function BEFORE the focus-command.

Hope that helps.
Regards,
Erwin Moller
Jul 20 '05 #2
Erwin Moller <si******************************************@spam yourself.com> wrote in message news:<3f***********************@news.xs4all.nl>...
jkstinn wrote:
I apologize for another post about focus, but whatever I try just
doesn't seem to work. I appreciate any ideas that you could give me on
getting the focus back to the textbox after tabbing or clicking out.
Jason

function checkTime(timeVal) {
var hr, mn;
if (timeVal.length != 4)
{
alert("Time entered must be 4 characters: ex. 0130.");
document.setCond.elements['hwtime'].focus();
}

<INPUT TYPE="text" NAME="hwtime" ID="hwTime" SIZE=4 MAXLENGTH=4
VALUE="Time" onfocus='this.value="";'
onchange='checkTime(this.value);'>


Hi,

What is setCond?
Difficult to say without the complete code.

I am sure the following code works:
document.forms.yourformnamehere.hwtime.focus();

where you have to replace yourformnamehere by the name of the form this
element is in.

Please also check you are not accidentally using the same formname and
elementname twice.
Why are you using an ID and a name? (Just curious)
You could also try to remove the onfocus='this.value="";' and place that in
the function BEFORE the focus-command.

Hope that helps.
Regards,
Erwin Moller

Erwin

setCond is the name of my form. I was using ID and names when I was
trying to access an element from different ways trying to get the
thing to work. I went ahaed and took out all the IDs', as you had said
that maybe I had a naming problem. That still didn't work. I was using
onchange to test the text for correct information. When I changed the
onchange to onblur, the focus() would work. What is the difference
between the onchange and onblur that would make the focus work?

Thank you for your help.

Jason
Jul 20 '05 #3

setCond is the name of my form. I was using ID and names when I was
trying to access an element from different ways trying to get the
thing to work. I went ahaed and took out all the IDs', as you had said
that maybe I had a naming problem. That still didn't work. I was using
onchange to test the text for correct information. When I changed the
onchange to onblur, the focus() would work. What is the difference
between the onchange and onblur that would make the focus work?
The difference is that onBlur means something like: "Loosing the focus"
and on change means: "changing the value"
You could also try to remove the onfocus='this.value="";' and place that in the function BEFORE the focus-command.

Did you try that?

Thank you for your help.

Jason


Good luck!

Regards,
Erwin
Jul 20 '05 #4

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

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
3
by: VA | last post by:
t=document.getElementById('mytable') is a HTML table with some input fields in its cells Why doesnt t.getElementsByTagName('tr').firstChild.focus; put the focus on that text field? It...
17
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
4
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between...
3
by: jp2express | last post by:
I have several applications that use panels as screens, but I can *not* seem to set the focus for a Textbox. Panel1.BringToFront() Panel1_Textbox.Focus() ' do something with a control on Panel1...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...
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
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...

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.