Q14
Question 14
Implement a static password protection.
Code
<html>
<head>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
    <title>Password Security (pass=staticpass) 
    | Javascript 2 </title>
    <script>
        function pass() {   
            var password;
            var staticPassword="staticpass";
            password=(document.getElementById("pass").value);
            if (password==staticPassword)
                alert("Password Correct!");
            else
               alert('Password Incorrect!');    
       }
   </script>
</head>
<body>
<div class="container-fluid ">
    <center>
        <div class="container mt-5">
            <h1>Password Security (pass=staticpass) 
            | Javascript 2 </h1>
        </div>
      </center> 
    <div class="form-group mt-5">
        <div class="container mt-2">
   <label for="email">Enter Email</label>  
        </div>
        <div class="container mt-2">
            <input class="form=control w-75 p-3" 
            type="email" id="email" 
            placeholder="[email protected]" required>
        </div><div class="container mt-2">
        <label for="pass"> Enter Password</label> 
        </div>
        <div class="container mt-2">
            <input type="password" 
            class="form-control w-75 p-3" 
            id="pass" 
            placeholder="Enter Password = staticpass" 
            required>
        </div>
        <div class="container mt-2">
            <button class="btn btn-primary" 
            onclick="pass()">
                <a>Submit</a>
            </button>
        </div>
        </div>
    </div>
    </div>
</body>
</html>Output



Try or Test The Corresponding Code Here
Last updated