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

Getting and Setting key character in key event

I have had this function work perfectly in IE and am trying to get it
to work in Firefox. I have seen plenty of questions and answers on the
web for how to get and check the key pressed but nothing about setting
or changing it. I only want uppercase characters in this case. If the
key is a lowercase, it needs to be changed to an uppercase character.
IE lets you use keyCode to change the character code. How do I do the
equivalent in Firefox?

<textarea cols="40" rows="3" name="Rule" id="Rule"
onkeypress="checkUppercase(event);"></textarea>

function checkUppercase(e) {
// Get ASCII value of key that user pressed
if (!e) e = window.event;
var key = e.keyCode ? e.keyCode : e.which;

// Was key that was pressed a lowercase letter from a-z or backspace?
if ( key < 97 || key 122 || key == 8 )
return; // if so, do nothing
else // make it uppercase
if (window.event)
e.keyCode = key - 32; // IE
else
// None of the following work for Firefox
e.which = key - 32;
e.charCode = key - 32;
}

Thanks,
Jeff

Aug 17 '07 #1
3 2512
Thanks for the replies. I want to do the same thing in Firefox that
happens in IE, and that is changing the character as it is typed so
that means not using the onchange event. Is there no way to do this in
Firefox?

In the meantime, thanks to a combination of replies, this will work,
although I still would like to do it character by character:

<textarea cols="40" rows="3" name="Rule" style="text-
transform:uppercase;"
onchange="this.value = this.value.toUpperCase();"></textarea>

Thanks,
Jeff

Aug 20 '07 #2
Jeff <dc******@hotmail.comwrote in news:1187622363.012098.95910
@i38g2000prf.googlegroups.com:
Thanks for the replies. I want to do the same thing in Firefox that
happens in IE, and that is changing the character as it is typed so
that means not using the onchange event. Is there no way to do this in
Firefox?

In the meantime, thanks to a combination of replies, this will work,
although I still would like to do it character by character:
doing it character by character will be infuriating to your users. try it
yourself. What happens when you try to backspace/enter a period/return
key, etc... It really interferes with the user experience IMHO. If you
must do it, try Richard's CSS solution, and then keep the javascript
relegated to the 'onchange'

Aug 20 '07 #3
On Aug 20, 11:56 am, Good Man <he...@letsgo.comwrote:
doing it character by character will be infuriating to your users. try it
yourself. What happens when you try to backspace/enter a period/return
key, etc... It really interferes with the user experience IMHO.
It has been working that way for over a year with no complaints from
the users. BTW, if anything other than a lowercase character is typed,
the function exits. The users are on an Intranet and as of right now
are only using IE but now we are making sure Firefox users will be
able to use the site. So I take it that there is no equivalent way in
Firefox to change the character typed like IE can do?
Aug 21 '07 #4

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

Similar topics

8
by: Harlin Seritt | last post by:
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget root =...
4
by: Andrew DeFaria | last post by:
I'm trying to use the onKeyDown event on a text field. I intersept the keystroke, interpret it and then do certain actions based on certain keys stuck. If a special key is stuck I replace the value...
3
by: Lachlan Hunt | last post by:
Hi, I've been looking up lots of documentation and trying to work out a cross-platform method of capturing a keyboard event and working out which key was pressed. From what I can find, there...
6
by: kurotsuke | last post by:
Hi, I'm trying to use the GetKeyName API to get the name of certain keys (in the system language). For example the names of SHIFT and RETURN keys as well as the names of same special characters....
8
by: Hazz | last post by:
What is the triggering action that raises the event which causes my breakpoint to be reached, repeatedly, but does not allow my form to ever remain visible. I set a breakpoint on the line...
0
by: Rob Tand | last post by:
Hello, I am creating a server side telnet application in managed C++. It supports multiple socket connections and sets an event up for receiving data from each telnet client. Currently, the...
2
by: Ken Kolda | last post by:
We're using .NET remoting hosted under IIS but we're running into problems with the server shutting down the ASP.NET worker process unexpectedly. Since I know this can occur because of the settings...
1
by: imranabdulaziz | last post by:
Dear All, I am mess with one situation let me explain the scenario. I am making search form where I display 15 field in checkboxlist and user select one or two or three or any no to all field....
1
by: ton | last post by:
Hi, I'm using Ajax to seach direct in a gridview. It works fine. I even keep the focus on the input text box. Here is my code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.