Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1708 How can I pass the value of a hidden field into a confirm dialog box when the submit button is pressed, so I can ask the user if they really want to edit/remove the visible version of the hidden value?

You are here: irt.org | FAQ | JavaScript | Form | Q1708 [ previous next ]




<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;



<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">

<script language="JavaScript"><!--
// reset visible form field in case user pages back to this page
document.myForm.visible.value = document.myForm.hidden.value;



©2018 Martin Webb