473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex OnKeyDown question

Hi - I have a regex defined as [^A-Z0-9] and I am trying to allow only
uppercase alphanumeric input in a textbox. So I have Uppercasing set
to true elsewhere in the program and I have an OnKeyDown event handler
with

e.SuppressKeyPr ess = false;

if (myRegex.IsMatc h(e.KeyData.ToS tring()))
e.SuppressKeyPr ess = true;

Problem is shift key is being matched in the regex so shiftkey + any
alpha key is being rejected.
Any help appreciated ...

Thanks in advance,
El Squid

Oct 21 '07 #1
1 1993
el***********@y ahoo.com wrote:
Hi - I have a regex defined as [^A-Z0-9] and I am trying to allow only
uppercase alphanumeric input in a textbox. So I have Uppercasing set
to true elsewhere in the program and I have an OnKeyDown event handler
with

e.SuppressKeyPr ess = false;

if (myRegex.IsMatc h(e.KeyData.ToS tring()))
e.SuppressKeyPr ess = true;

Problem is shift key is being matched in the regex so shiftkey + any
alpha key is being rejected.
Any help appreciated ...
Unless you specifically care about the exact key on the keyboard that
was pressed, you should be using the OnKeyPressed method instead of
OnKeyDown.

Note that _neither_ method is an event handler. A minor quibble in this
context, but the difference is important.

Pete
Oct 21 '07 #2

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

Similar topics

6
3903
by: Z | last post by:
I have sub-classed the TextBox. In its OnKeyDown event I can intercept key strokes, examine them, etc. When I get a certain keycode (e.g., 'A') I want to change it to another unicode key from a different code page (e.g., "\u2801"). But the KeyCode, KeyData, and KeyValue properties of KeyEventArgs are all only getters. They are read only and thus do not permit changing the assigned KeyCode. My question is this: How do I change the KeyCode...
5
1431
by: Russell Campbell | last post by:
I was using onKeyDown to change Enter to Tab. However, in a textarea, this prevents a CRLF from being entered and just moves you to the next field. So I thought if I put an onKeyDown on the textarea and pass a parameter that effectively just tells it to do nothing in that case, then the onKeyDown on the textarea would override the one associated with the body tag. No luck, though. What would be the proper technique here? Thanks for...
3
7394
by: euler | last post by:
why did the keydown event not fire in this simple example? <HTML> <HEAD><title>keydown_div</title> <script type="text/javascript"> function keydown() { alert("keydown"); } </script>
10
9155
by: b.dam | last post by:
I'm trying the following: function grid() { this._el = document.createElement("TABLE"); var self = this; document.addEventListener("onkeydown", function(event) {self.gridKeyDown(event);}, false); }
5
2694
by: Dave Henson | last post by:
Hi I am checking a site for accessibility and Dreamweaver suggests making sure that the menu is accessible via keyboard as well as mouse (i.e device-independent). A question has arisen which is probably more to do with my lack of understanding of how a user might interact with a web site without using a mouse. I have tried using the onKeyDown command but it does not seem to be key-specific. If this command is added to eight menu...
17
3961
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher http://forta.com/books/0672325667/
5
3786
by: Roger Withnell | last post by:
I'm using the following code to start a function on key down. document.onkeydown = OnKeyDown; function OnKeyDown() { vKeyCode = event.keyCode; ..code... }
1
5744
eboyjr14
by: eboyjr14 | last post by:
I have this UserScript for Grease monkey. but I can't get the onleydown event to fire in FIREFOX only. I've looked everywhere! // ==UserScript== // @name iGoogle Suggest // @namespace Devin Samarin // @description This automatcally selects the top result for your query. // @include *google.com/ig* // ==/UserScript== function makeRequest() {
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.