<input id="number" oninput="validation(this)" type="text" />
var tmp = ''; function validation(that) { if(that.value.match(/^[0-9]+$/)) tmp = that.value; else that.value = tmp; }