<input name="number" onkeyup="if (/D/g.test(this.value)) this.value = this.value.replace(/D/g,'')"> Run code snippet