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

only type of kesytroke in textfields

Ike
Can anyone please point me to an example showing a textfield that only
allows a certain kind of character typed in? I need to create a text field
where only an opening or closing parentheses can be input ('(' or ')').

TIA, Ike
May 15 '06 #1
2 1010
Ike said the following on 5/15/2006 3:07 PM:
Can anyone please point me to an example showing a textfield that only
allows a certain kind of character typed in? I need to create a text field
where only an opening or closing parentheses can be input ('(' or ')').


Search the archives for onkeyup, onkeydown, and onkeypress. You will
find code that does what you are after, you will just have to modify it
to your own needs.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 15 '06 #2
Ivo
"Ike" schreef
Can anyone please point me to an example showing a textfield that only
allows a certain kind of character typed in? I need to create a text field
where only an opening or closing parentheses can be input ('(' or ')').


Seems to me that a textfield is not the best suited for this job, where
<select>
<option value="(">(</option>
<option value=")">)</option>
</select>
does the job without any script at all! Radiobuttons are great for this sort
of thing too.
Otheriwse, with 40 and 41 being the character codes for respectively the
opening or closing parentheses, the following code will return false and so
nullify the event for all other characters.

<input onkeypress="var k = event.keyCode || event.charCode || event.which;
return k===40 || k===41;">

hth
ivo
http://4umi.com/web/javascript/
May 15 '06 #3

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

Similar topics

3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
1
by: Filips Benoit | last post by:
Dear All, After copying a record using an Stored procedure all textfields (nvarchar) has max lenght ! See VBA-code and SP below VBA-code tos execute SP
1
by: Ed | last post by:
Hi, I have an html page with a div element within a form for dynamically creating textfields. The problem is when I click a link on the page, or the submit button, then click the back button,...
6
by: anirban.anirbanju | last post by:
hi there, i've some serious problem to add rows dynamically in a table. my table contains 5 cell. | check | from_value | to_value | color_text | color_value |...
0
by: chandutp | last post by:
hi i am new to this forum can i populate datagrid items of asp page to another asp page having textfields. in this datagrid userId is the index key by which it referenced.and i am using edit...
1
by: eureka | last post by:
Hi folks, I am working on a webapplication using Jsp and JS. On my main Jsp(Jsp1) I have a table which is created dynamically inside a <divand contains all the backend-table's records as rows,...
5
by: pradeep84 | last post by:
Hi.. to all... in the following program i hav retrived data from the database and stored in the string s2,s3... now i hav display the following string in the textfields... i dont know how.. to do...
5
by: Kevin R | last post by:
How do you create those small textfields that I see for inputing passwords and such? Kevin
2
by: f3dde | last post by:
Hi there, I have a question about forms in MS Access.. Is it possible in any way at all, to add info in 2 textfields and save it as 1 record. Detail: I have a record with 3 fields....
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.