jQuery Compare Password Example

<!DOCTYPE html>
<html>
<head>
    <title>Compare Password</title>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#button").click(function(){
                if($("#password").val() == $("#cpassword").val()){
                alert("Password Matched");
            }
            else{
                alert("Password Not Matched");
            }
            });           
        });
    </script>
</head>
<body>
<form id="form">
    <input type="password" id="password" placeholder="Password"><br><br>
    <input type="password" id="cpassword" placeholder="Confirm Password"><br>
    <input type="submit" id="button" value="Compare">
</form>
</body>
</html>

Comments