function validate(evt) {
var theEvent = evt || window.event;
var target = theEvent.target || theEvent.srcElement;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = /[0-9]|/;
if( !regex.test(key) || (!target.value.length && !+key)) {
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}