You are here: irt.org | FAQ | JavaScript | Form | Q1708 [ previous next ]
Try:
<html> <head> <script language="JavaScript"><!-- function validate() { if (document.myForm.hidden.value != document.myForm.visible.value) return confirm('Is this the correct value: ' + document.myForm.visible.value); return true; } //--></script> </head> <body> <form name="myForm" onSubmit="validate()"> <input type="hidden" name="hidden" value="Hello world"> <input type="text" name="visible" value="Hello world"> <input type="submit" value="Submit"> </form> <script language="JavaScript"><!-- // reset visible form field in case user pages back to this page document.myForm.visible.value = document.myForm.hidden.value; //--></script> </body> </html>