<input type="text" name="txt" onBlur="if (parseInt(this.value)<1000 || parseInt(this.value)>4999) txt.focus();">