Connecting Tech Pros Worldwide Help | Site Map

focus

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 11:24 AM
jkstinn
Guest
 
Posts: n/a
Default 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);'>

  #2  
Old July 20th, 2005, 11:24 AM
Erwin Moller
Guest
 
Posts: n/a
Default Re: focus

jkstinn wrote:
[color=blue]
> 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);'>[/color]

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
  #3  
Old July 20th, 2005, 11:25 AM
jkstinn
Guest
 
Posts: n/a
Default Re: focus

Erwin Moller <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in message news:<3f9e34f1$0$58707$e4fe514c@news.xs4all.nl>...[color=blue]
> jkstinn wrote:
>[color=green]
> > 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);'>[/color]
>
> 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[/color]
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
  #4  
Old July 20th, 2005, 11:26 AM
Erwin Moller
Guest
 
Posts: n/a
Default Re: focus

[color=blue]
>
> 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?[/color]

The difference is that onBlur means something like: "Loosing the focus"
and on change means: "changing the value"
[color=blue]
> You could also try to remove the onfocus='this.value="";' and place that[/color]
in the function BEFORE the focus-command.

Did you try that?
[color=blue]
>
> Thank you for your help.
>
> Jason[/color]

Good luck!

Regards,
Erwin
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.