| Current Path : /home/emeraadmin/public_html/Service/ |
| Current File : /home/emeraadmin/public_html/Service/ex.html |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple CAPTCHA</title>
<style>
/* Reset some basic styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f7f7f7;
color: #333;
}
.form-container {
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
text-align: center;
}
h2 {
margin-bottom: 20px;
font-size: 24px;
font-weight: 600;
color: #444;
}
.captcha-container {
margin-bottom: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f1f1f1;
}
.captcha {
font-size: 24px;
font-weight: bold;
color: #3498db;
}
.captcha input {
padding: 10px;
margin-top: 10px;
width: 100%;
font-size: 18px;
border: 1px solid #ccc;
border-radius: 8px;
outline: none;
}
.captcha input:focus {
border-color: #3498db;
}
.captcha-error {
color: red;
font-size: 14px;
margin-top: 10px;
display: none;
}
.submit-btn {
padding: 12px 30px;
background-color: #3498db;
color: #fff;
font-size: 16px;
font-weight: bold;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
}
.submit-btn:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Please verify you're human</h2>
<!-- CAPTCHA Section -->
<div class="captcha-container">
<span class="captcha" id="captchaText"></span>
<input type="text" id="captchaInput" placeholder="Enter CAPTCHA" required>
<div class="captcha-error" id="captchaError">CAPTCHA is incorrect. Please try again.</div>
</div>
<!-- Submit Button -->
<button class="submit-btn" id="submitBtn">Submit</button>
</div>
<script>
// Generate a random CAPTCHA string
function generateCaptcha() {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let captcha = '';
for (let i = 0; i < 6; i++) {
captcha += chars.charAt(Math.floor(Math.random() * chars.length));
}
document.getElementById('captchaText').textContent = captcha;
return captcha;
}
// Initially generate CAPTCHA
const captchaCode = generateCaptcha();
// Form submission handler
document.getElementById('submitBtn').addEventListener('click', function(event) {
event.preventDefault(); // Prevent form submission
// Check if CAPTCHA entered by user is correct
const userCaptcha = document.getElementById('captchaInput').value;
if (userCaptcha !== captchaCode) {
document.getElementById('captchaError').style.display = 'block';
// Regenerate CAPTCHA
generateCaptcha();
} else {
document.getElementById('captchaError').style.display = 'none';
// Redirect to example.com after successful CAPTCHA validation
window.location.href = "https://example.com"; // Redirect to the desired URL
}
});
</script>
</body>
</html>