Gregniuki commited on
Commit
7aface5
·
1 Parent(s): 13ebb53

Update templates/register.html

Browse files
Files changed (1) hide show
  1. templates/register.html +22 -13
templates/register.html CHANGED
@@ -4,7 +4,7 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Register</title>
7
- <link rel="stylesheet" type="text/css" href="static/style.css"> <!-- Add this line for your CSS -->
8
 
9
  </head>
10
  <body>
@@ -38,10 +38,7 @@
38
  </form>
39
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
40
  <script>
41
- function onSubmit(token) {
42
- document.getElementById('recaptcha_token').value = token; // Assign the token to the hidden input
43
- document.getElementById('registration-form').submit(); // Submit the form
44
- }
45
 
46
  function validateForm() {
47
  // Here, you would put any form validation logic you need.
@@ -50,18 +47,30 @@
50
  }
51
 
52
  // When the form is submitted
53
- document.getElementById('registration-form').addEventListener('submit', function(event) {
54
- var formValid = validateForm();
55
-
56
- if (!formValid) {
57
- // If the form is not valid, prevent submission
58
- event.preventDefault();
59
- } else {
60
- // If the form is valid, invoke reCAPTCHA check
 
 
 
61
  grecaptcha.execute();
 
 
 
62
  }
63
  });
64
 
 
 
 
 
 
 
65
  // When reCAPTCHA is ready, we can auto-invoke or you can bind it to a button click as well
66
  grecaptcha.ready(function() {
67
  // grecaptcha.execute(); // Uncomment this line if you want to auto-invoke reCAPTCHA
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Register</title>
7
+ <link rel="stylesheet" type="text/css" href="templates/style.css"> <!-- Add this line for your CSS -->
8
 
9
  </head>
10
  <body>
 
38
  </form>
39
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
40
  <script>
41
+
 
 
 
42
 
43
  function validateForm() {
44
  // Here, you would put any form validation logic you need.
 
47
  }
48
 
49
  // When the form is submitted
50
+ document.getElementById('registration-form').addEventListener('submit', function(event) {
51
+ event.preventDefault();
52
+ // Check if all fields are filled out
53
+ var username = document.getElementById('username').value;
54
+ var email = document.getElementById('email').value;
55
+ var password = document.getElementById('password').value;
56
+ var confirmPassword = document.getElementById('confirm_password').value;
57
+
58
+ // You could also check for other constraints here, like password match, etc.
59
+ if(username && email && password && confirmPassword) {
60
+ // All fields are filled, execute reCAPTCHA
61
  grecaptcha.execute();
62
+ } else {
63
+ // Not all fields are filled, perhaps show an error message or alert
64
+ alert("Please fill in all required fields.");
65
  }
66
  });
67
 
68
+ // Callback function to be called once reCAPTCHA is solved
69
+ function onSubmit(token) {
70
+ document.getElementById('recaptcha_token').value = token; // Assign the token to the hidden input
71
+ document.getElementById('registration-form').submit(); // Submit the form
72
+ }
73
+
74
  // When reCAPTCHA is ready, we can auto-invoke or you can bind it to a button click as well
75
  grecaptcha.ready(function() {
76
  // grecaptcha.execute(); // Uncomment this line if you want to auto-invoke reCAPTCHA