Re-type Password Validation

Example

<html>
<head>
<script>
function pass_validation()
{
var firstpassword=document.f1.password1.value;  
var secondpassword=document.f1.password2.value;  

if(firstpassword==secondpassword){  
return true;  
}  
else{  
alert("password one and two must be same!");  
return false;  
}  
} 
</script>
</head>

<body>
<form name="f1" action="/JavaScript/Index" onsubmit="return pass_validation()">  
Password:<input type="password" name="password1" /><br/>  
Re-enter Password:<input type="password" name="password2"/><br/>  
<input type="submit">  
</form> 
</body>
</html>

Result

Password:
Re-enter Password: