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

onkeyup work only for the first number inserted ?

den
<input id="txtTop" type="text" onkeyup="fun_control(this)"/>

function fun_control(var2)
{ if ((var2.value== 0) || (var2.value== 1) ||
(var2.value== 2) || (var2.value== 3) )
{alert('ok is a number');}
}
work only for the first number that I insert;
is possible to resolve?
Mar 7 '07 #1
1 1756
On Mar 7, 1:19 pm, den <spam...@not.notwrote:
<input id="txtTop" type="text" onkeyup="fun_control(this)"/>

function fun_control(var2)
{ if ((var2.value== 0) || (var2.value== 1) ||
(var2.value== 2) || (var2.value== 3) )
{alert('ok is a number');}

}

work only for the first number that I insert;
is possible to resolve?
if you want to disable all other keys-
change html part to -
<input id="txtTop" type="text" onkeypress="return fun_control(this)" /
>
and script part to-
function fun_control(evt){
evt=String.fromCharCode((event||evt).keyCode)
return (/[1-4]/.test(evt))
}

you can remove the charCode part and change the number-set in test
method to 49-52.

Mar 7 '07 #2

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

Similar topics

3
by: Trent | last post by:
Hi. I know the basic way to assign event handlers: <input onKeyUp="processEvent(event)" /> But how do I assign a function to the onKeyUp event in *javascript* that can access the event...
2
by: Evan Wong | last post by:
I have problem to get onkeyup event. If we put the event in HTML statement like - "<input name=field1 size=16 onkeyup="javascript:function1();>" it works. If we put in JavaScript code like...
2
by: greg | last post by:
hello i would like to apply an onkeyup event to every element of my form in order to do that, i would use the array form.elements, doing something like that : ...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
2
by: William Barnes | last post by:
Using VS .NET 2003 on an up-to-date XP Pro machine: I'm getting bizarre results in a VB Windows app trying to implement the OnKeyUp event handler. I have a form with a label control and code...
3
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the...
13
by: Lee | last post by:
I have this function that doesn't work. I pass it the td element and an id, and it makes an input field inside the td. That part workds. What doesn't work is that I want to add an "onkeyup" on...
0
by: bughunter | last post by:
I found code from java - real bug with secondary parameter, should be Integer but called with String, But procedure completed without any errors and parameter correctly transformed to integer! ...
6
by: kodt | last post by:
I have a form with 4 text input fields. The last one is the total of the previous three fields and should automatically calculate this value when a user enters data into any of the first 3. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.