Connecting Tech Pros Worldwide Help | Site Map

Checking focus on an element in interaction with uppercase function

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 29th, 2008, 03:25 PM
Newcomsas
Guest
 
Posts: n/a
Default Checking focus on an element in interaction with uppercase function

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, 05:05 PM
Bart Van der Donck
Guest
 
Posts: n/a
Default Re: Checking focus on an element in interaction with uppercasefunction

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

 

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.