Moving Login Button Project (Troll Form 😂)
If the user enters an incorrect password, the "Login" button moves away!
<html>
<head>
<style>
.container {
text-align: center;
margin-top: 50px;
}
.btn {
position: relative;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
<script>
function moveButton() {
let password = document.getElementById("password").value;
let button = document.getElementById("btn");
if (password !== "legend") {
let x = Math.random() * (window.innerWidth - 100);
let y = Math.random() * (window.innerHeight - 100);
button.style.position = "absolute";
button.style.left = x + "px";
button.style.top = y + "px";
}
}
</script>
</head>
<body>
<div class="container">
<h2>Enter Password</h2>
<input type="password" id="password" placeholder="Type something..." oninput="moveButton()">
<br><br>
<button id="btn" class="btn" onclick="alert('You got lucky!')">Login</button>
</div>
</body>
</html>
How It Works?
If the user types anything other than "legend", the login button starts running away from the cursor.
If the correct password is entered, the button stays in place.
Web Development Best Resources
ENJOY LEARNING 👍👍
#webdev
If the user enters an incorrect password, the "Login" button moves away!
<html>
<head>
<style>
.container {
text-align: center;
margin-top: 50px;
}
.btn {
position: relative;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
<script>
function moveButton() {
let password = document.getElementById("password").value;
let button = document.getElementById("btn");
if (password !== "legend") {
let x = Math.random() * (window.innerWidth - 100);
let y = Math.random() * (window.innerHeight - 100);
button.style.position = "absolute";
button.style.left = x + "px";
button.style.top = y + "px";
}
}
</script>
</head>
<body>
<div class="container">
<h2>Enter Password</h2>
<input type="password" id="password" placeholder="Type something..." oninput="moveButton()">
<br><br>
<button id="btn" class="btn" onclick="alert('You got lucky!')">Login</button>
</div>
</body>
</html>
How It Works?
If the user types anything other than "legend", the login button starts running away from the cursor.
If the correct password is entered, the button stays in place.
Web Development Best Resources
ENJOY LEARNING 👍👍
#webdev
❤2🔥1