Connecting Tech Pros Worldwide Help | Site Map

Checking focus on an element in interaction with uppercase function

  #1  
Old August 29th, 2008, 04:25 PM
Newcomsas
Guest
 
Posts: n/a
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))
window.event.keyCode = key-0x20;
}

....and it works fine.
I have got an HTML form with many textboxes; until now I performed the
uppercase in all of them.
Now my customer asked me to let the users insert lowcase characters in
just one of them.
I think the best way should be to test the focus on this one
textbox... Fact is, I did not find a satisfactory way to check the
property: a myTextBox.hasFocus does not exist indeed.

Is there anyone who knows how it is possible to do that ? I would like
to be able to change my function more or less in this way:

if (((key 0x60) && (key < 0x7B)) && (myTextBox.hasFocus==false))
etc.

i thank you in advance for your help,

Newcomsas
  #2  
Old August 29th, 2008, 06:05 PM
Bart Van der Donck
Guest
 
Posts: n/a

re: Checking focus on an element in interaction with uppercase function


Newcomsas wrote:
Quote:
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))
window.event.keyCode = key-0x20;
>
}
>
...and it works fine.
I have got an HTML form with many textboxes; until now I performed the
uppercase in all of them.
Now my customer asked me to let the users insert lowcase characters in
just one of them.
I think the best way should be to test the focus on this one
textbox... Fact is, I did not find a satisfactory way to check the
property: a myTextBox.hasFocus does not exist indeed.
>
Is there anyone who knows how it is possible to do that ? I would like
to be able to change my function more or less in this way:
>
if (((key 0x60) && (key < 0x7B)) && (myTextBox.hasFocus==false))
etc.
Your strategy is not optimal. I would definitely go for a different
approach. In so far I can see,

<input onKeyUp="this.value = this.value.toUpperCase();">

does exactly the same as your function. Personally I would go for

<input style="text-transform: uppercase;">

but form data arrives then at the server "as typed". It could be
uppercased there at wish.

Obviously the opposite is also possible:

<input onKeyUp="this.value = this.value.toLowerCase();">
<input style="text-transform: lowercase;">

Hope this helps,

--
Bart
Bart

Closed Thread