<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD//xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Illustrate password checking</title>
<script language="javascript" type="text/javascript" >
<!--
function chkPasswords(){
var init=document.getElementById("initial");
var sec=document.getElementById("second");
if(init.value==""){
alert("You did not enter a password\n"+"Please enter one now");
init.focus();
return false;
}
if(init.value!=sec.value){
alert("The two passwords you entered are not the same\n"+"Please re-enter both now");
init.focus();
init.select();
return false;
}
else return true;
}
//-->
</script>
</head><body>
<h3>Password Input</h3>
<form id="myForm" action="">
<p>
Your password
<input type="password" id="initial" size="10"/>
<br><br>
Verify password
<input type="password" id="second" size="10"/>
<br><br>
<input type="reset" name="reset"/>
<input type="submit" name="submit"/>
</p>
</form>
<script type="text/javascript">
<!--
window.onload = new function(){
document.getElementById("second").onblur= function(){chkPasswords();}
document.getElementById("myForm").onsubmit= function(){chkPasswords();}
}
//-->
</script>
</body>
</html>