<script type="text/javascript">
function data_change(field){
var check = true;
var value = field.value;
for(var i=0;i < field.value.length; ++i) {
var new_key = value.charAt(i);
if(((new_key < "0") || (new_key > "9")) && !(new_key == "")) {
check = false;
break;
}
}
if(!check) {
field.style.backgroundColor = "red";
} else {
field.style.backgroundColor = "white";
}
}
</script>
<input type="text" onkeyup="data_change(this);">