File size: 2,952 Bytes
0c6c1fb dc1083b 708c3d6 0c6c1fb 13ebb53 af04874 d338b03 13ebb53 94d664a 13ebb53 b8c4bc1 708c3d6 7aface5 13ebb53 708c3d6 13ebb53 7aface5 13ebb53 7aface5 13ebb53 7aface5 13ebb53 708c3d6 13ebb53 708c3d6 13ebb53 0c6c1fb |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register</title>
<link rel="stylesheet" type="text/css" href="/static/style.css"> <!-- Add this line for your CSS -->
</head>
<body>
<h1>Register</h1>
<form action="/register" method="post" id="registration-form">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label for="confirm_password">Confirm Password:</label>
<input type="password" id="confirm_password" name="confirm_password" required><br><br>
<!-- Hidden field for the reCAPTCHA token -->
<input type="hidden" id="recaptcha_token" name="recaptcha_token" value="">
<!-- reCAPTCHA widget -->
<div class="g-recaptcha"
data-sitekey="6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl"
data-callback="onSubmit" >
</div>
<br/>
<button type="submit">Register</button>
</form>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function validateForm() {
// Here, you would put any form validation logic you need.
// For demonstration purposes, let's assume it always returns true.
return true;
}
// When the form is submitted
document.getElementById('registration-form').addEventListener('submit', function(event) {
event.preventDefault();
// Check if all fields are filled out
var username = document.getElementById('username').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
var confirmPassword = document.getElementById('confirm_password').value;
// You could also check for other constraints here, like password match, etc.
if(username && email && password && confirmPassword) {
// All fields are filled, execute reCAPTCHA
grecaptcha.execute();
} else {
// Not all fields are filled, perhaps show an error message or alert
alert("Please fill in all required fields.");
}
});
// Callback function to be called once reCAPTCHA is solved
function onSubmit(token) {
document.getElementById('recaptcha_token').value = token; // Assign the token to the hidden input
document.getElementById('registration-form').submit(); // Submit the form
}
// When reCAPTCHA is ready, we can auto-invoke or you can bind it to a button click as well
grecaptcha.ready(function() {
// grecaptcha.execute(); // Uncomment this line if you want to auto-invoke reCAPTCHA
});
</script>
</body>
</html>
|