01.
function
validate(evt) {
02.
var
theEvent = evt || window.event;
03.
var
key = theEvent.keyCode || theEvent.which;
04.
key = String.fromCharCode( key );
05.
var
regex = /[0-9]|\./;
06.
if
( !regex.test(key) ) {
07.
theEvent.returnValue = false;
08.
if
(theEvent.preventDefault) theEvent.preventDefault();
09.
}
10.
}