<input type="number" onKeyPress="if(this.value.lenth==4) return false;">