Search | Directories | Reference Tools
UW Home > Discover UW > Site Information > Guidelines 

Javascript Form Script

The relevant code from the javascript "cancel-confirmation" form example is shown below. When implementing this script, be sure that the function and variable names are set correctly (see colored text below).

<SCRIPT language="JavaScript">
<!-- Hide the script from old browsers --
var dataOK=false;

function ConfirmCancel (){
  if (confirm("Are you sure you want to clear the form? Click OK to clear it."))
  return true;


<form name="myForm">
Comments: <br>
<textarea wrap rows="5" cols="50"></textarea><br>
<input type="SUBMIT" value="Send Comments"><br>
<input type="button" value="Erase Form" onClick="ConfirmCancel()">