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.