You are here: irt.org | FAQ | JavaScript | Form | 3.6 | Q1222 [ previous next ]
Try this:
<form name="myForm"> <input type="text" name="myTextField" value="" onFocus="if (this.disabled) { this.value = saveValue; setTimeout('document.myForm.myTextField.blur()',1); } else saveValue=this.value;"> <input type="checkbox" onClick="if (this.checked) { saveValue=this.form.myTextField.value; this.form.myTextField.disabled = true; } else this.form.myTextField.disabled = false;"> Disable </form> <script language="JavaScript"><!-- document.myForm.myTextField.disabled = false; saveValue=""; //--></script>