<input name="input" value="" onKeyUp="if (this.value.length <= 5) {document.getElementById('input_2').value = this.value;}"> <input id="input_2" name="input_2" value="">