-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (28 loc) · 1.17 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let captchaText = "";
function generateCaptcha() {
const canvas = document.getElementById("captchaCanvas");
const ctx = canvas.getContext("2d");
canvas.width = 200;
canvas.height = 80;
captchaText = Math.random().toString(36).substring(2, 8).toUpperCase();
ctx.fillStyle = "#333";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
ctx.font = "bold 30px Arial";
ctx.filter = "blur(2px)";
ctx.fillText(captchaText, 30, 50);
ctx.filter = "none";
}
function verifyCaptcha() {
const userInput = document.getElementById("captchaInput").value.toUpperCase();
const result = document.getElementById("result");
if (userInput === captchaText) {
result.innerText = "✅ Correct!";
result.style.color = "green";
} else {
result.innerText = "Verification Failed.";
result.style.color = "red";
generateCaptcha();
}
}
generateCaptcha();