Kaut kā apmēram šitā :
(function(){
function in_array( what, where ){
var a=false;
for( var i=0; i<where.length; i++ ){
if( what == where[i] ){
a=true;
break;
}
}
return a;
}
function validate( e ) {
var e = e || window.event;
var keycode = e.keyCode || e.which;
key = String.fromCharCode( keycode );
var regex = /[0-9]|\./;
if( !regex.test(key) && ( !in_array( keycode , [ 8 , 9, 35, 36, 37, 38, 39, 40, 45, 46] ))) {
e.returnValue = false;
e.preventDefault();
}
}
docuemnt.getElementById( 'digital' ).onkeypress = validate;
})();
Neesmu notestējis.