Internet Technologies
1.0.0
1.0.0
  • Introduction
  • Contents
  • Practical List
  • HTML & CSS
    • Q1
    • Q2
    • Q3
    • Q4
    • Q5
  • JAVA Programs
    • Q6
    • Q7
    • Q8
    • Q9
    • Q10
    • Q11
    • Q12
  • JAVASCRIPT
    • Q13
    • Q14
    • Q15
  • JDBC
    • Q16
    • Q17
  • JSP
    • Side Note
    • Q18
    • Q19
    • Q20
    • Q21
    • Q22
    • Q23
  • End
Powered by GitBook
On this page
  • Code
  • Output
  1. JAVASCRIPT

Q14

Question 14

PreviousQ13NextQ15

Last updated 4 years ago

Implement a static password protection.

Stored password statically in script as Javascript code and validating it by picking password id and Alert Box

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

Browse Source Code
Live Demo javascript_2.html
2KB
javascript_2.html
Download javascript_2.html
Main Page (1/3)
Entering Wrong Password (2/3)
Entered Corrected Password (3/3)