Source of: /ch09/example.9-6.html
<!DOCTYPE HTML PUBLIC
              "-//W3C//DTD HTML 4.0 Transitional//EN"
              "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>Password Validation</title>
<script type="text/javascript">
<!-- Hide the script
function thesame(value1, value2)
{
  if (((value1 != null) || (value1 != ""))
       && value2 != "" && value1 != value2)
  {
       alert("The passwords must be identical.");
       return (false);
  }
  return (true);
}
// end hiding -->
</script>
</head>

<body>
<h1>Username Form</h1>
<form method="post" action="test.php" name="userForm">
<br>Username: <input type="text" name="userName" size=10>
<br>Password:
  <input type="password" name="formPassword1" size=10
  onchange="thesame(document.userForm.formPassword1.value,
                    document.userForm.formPassword2.value);">
<br>Re-enter password:
  <input type="password" name="formPassword2" size=10
  onchange="thesame(document.userForm.formPassword2.value,
                    document.userForm.formPassword1.value);">
<br><input type="submit" value="SUBMIT">
</form>
</body>
</html>