473,385 Members | 2,015 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,385 software developers and data experts.

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
Aug 29 '08 #1
1 1559
Newcomsas wrote:
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

Aug 29 '08 #2

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

Similar topics

3
by: leiko | last post by:
I've written the following function who works great in IE function OnlyCharacter(tekst) { if (tekst.length == 1) { if (tekst >= "A" && tekst <="Z") {return true} } window.alert ("Only...
3
by: Christoph Weber | last post by:
Hello, is there a function with which I can find out if a form element has the focus? Something like: function ReactIfFocus() { for(var i=0; i<10; i++) if( HasFocus(document.forms.elements)...
3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
5
by: Rune Runnestø | last post by:
How do I focus the cursor in the input field 'numberField' when accessing this jsp-file (or html-file) ? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>...
3
by: Philip Townsend | last post by:
I have an aspx page that contains 2 user controls, each containing a seperate textbox and button. I would like to specify that one of the buttons recieve focus when the page loads. Also, I would...
9
by: fidodido | last post by:
If in the textarea (textarea3), the value is not "abc", and the user uses "Tab" to go to the next textarea (textarea4), it will alert an error message...and the focus will return to the textarea...
3
by: Burak Kadirbeyoglu | last post by:
Dear Developers, I have a simple question. There's a textbox and an imagebutton on my page. When I focus on the textbox and hit enter, the imagebutton is being clicked. However, when I click...
2
by: yawnmoth | last post by:
Say I have two input elements and that I wanted to make it so that when the first ones input was what it should be, the focus would automatically be shifted to the next input element. ie....
2
dlite922
by: dlite922 | last post by:
Before traversing my code, here's what my goal is and what this function does: I have a table of fields that dynamically grows as the user enters information. A minimum of 3 rows must always...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.