This is a simple password protected website that utilizes the prompt()
function of JavaScript. The user is prompted to enter a password, and access to the website is granted only if the correct password is provided.
- HTML
- CSS
- JavaScript
-
When the user loads the website, a JavaScript function is triggered to prompt the user for a password.
-
The entered password is compared to a pre-defined password stored in the JavaScript code.
-
If the entered password matches the pre-defined password, the user is granted access to the website.
-
If the entered password does not match, the user is denied access and an error message is displayed.
To run the password protected website locally, follow these steps:
- Clone this repository to your local machine.
- Open the
index.html
file in your preferred web browser. - The website will prompt you to enter a password.
- Enter the correct password to access the website.
// Prompt the user for a password
var password = prompt("Please enter the password:");
// Define the correct password
var correctPassword = "mysecretpassword";
// Compare the entered password with the correct password
if (password === correctPassword) {
// Access granted
alert("Welcome! You have successfully logged in.");
// Additional code to display the protected content of the website
} else {
// Access denied
alert("Incorrect password. Please try again.");
}
This project is licensed under the MIT License.
Feel free to customize and use this password protected website for your own purposes. You May Visit The Website By Clicking Here.
Contributions to this project are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request , we will try to review and merge as soon as possible. Front-End Development Is Welcomed!