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

text area key capture

I'm a javascript newbie. How can I can I check user input using the keypress
or keydown events prior to it being displayed in the textbox? What I want
to be able to do is to check the keycode to against a pre-determined string
to see if the key is valid input? If it is not it won't be displayed in the
textbox.

Thanks,
Jim
Jul 23 '05 #1
1 1416
Lee
JimO said:

I'm a javascript newbie. How can I can I check user input using the keypress
or keydown events prior to it being displayed in the textbox? What I want
to be able to do is to check the keycode to against a pre-determined string
to see if the key is valid input? If it is not it won't be displayed in the
textbox.


It's generally better to wait until they finish typing, and then
check for invalid characters. If you block characters, you open
yourself up to a couple of bad scenarios:

1) the user thinks your page is broken, and either reports it
to you (or your boss) or simply stops using it.

2) the user is typing along, accidentally hits an invalid key,
realizes it and hits the backspace. Since you already removed
the invalid key, their backspace deletes the previous character,
possibly without their noticing it.

Besides these cases, you still aren't protecting yourself from
invalid characters unless you validate the input on the server,
too.

Jul 23 '05 #2

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

Similar topics

9
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I...
3
by: Marcob | last post by:
Is there any component out there to capture screen text from a specific region on any active external application form. Thanks Marco
10
by: Jake Barnes | last post by:
This weekend I wanted to learn AJAX, so I set up a little toy page where I could experiment. The idea of this page is that you click in one of the boxes to get some controls, at which point you can...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
0
by: VorTechS | last post by:
I'm having a problem with an inherited label, applying text rotation to aligned text. If text rotation is applied to the aligned text, the alignment goes 'nuts'. I can find no logic to what is...
12
by: Boris Borcic | last post by:
Hello, I am trying to use UI Automation to drive an MS Windows app (with pywinauto). I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't...
6
by: ffreino | last post by:
Hi, I'm trying to capture text between two words in a multi-line string. For example: 89. This is the text I would like to capture. This is another line. 90. End of the example. I would like...
1
by: =?Utf-8?B?Sm9obiBHcmF2ZXM=?= | last post by:
Does any one know how to caputer text data sent to a printer to a file. I have seen a window service that captures text data sent to a printer on the server and save it to a file. I would like to...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.