|
75 | 75 | } |
76 | 76 | } |
77 | 77 |
|
78 | | - // Check if form was filled too quickly (likely bot) |
79 | | - function isFormTooFast() { |
80 | | - const timeElapsed = Date.now() - formStartTime; |
81 | | - return timeElapsed < 3000; // Less than 3 seconds is suspicious |
82 | | - } |
83 | | -
|
84 | 78 | // Validate form submission |
85 | 79 | function validateForm(event) { |
86 | 80 | const target = event.target; |
|
94 | 88 | return false; |
95 | 89 | } |
96 | 90 |
|
97 | | - // Check if form was submitted too quickly |
98 | 91 | if (isFormTooFast()) { |
99 | 92 | event.preventDefault(); |
100 | 93 | console.log('Bot detectado: formulario enviado muy rápido'); |
101 | 94 | alert('Por favor, espera unos segundos antes de enviar el formulario.'); |
102 | 95 | return false; |
103 | 96 | } |
104 | 97 |
|
105 | | - // Check Turnstile (if enabled) |
106 | 98 | console.log('Verificando respuesta de Turnstile:', turnstileResponse); |
107 | 99 | console.log('ID del widget de Turnstile:', turnstileWidgetId); |
108 | 100 | console.log('isTurnstileLoaded:', isTurnstileLoaded); |
|
113 | 105 | return false; |
114 | 106 | } |
115 | 107 |
|
116 | | - // If validation passes, allow form submission to Brevo |
117 | 108 | console.log('Validación del formulario pasada, enviando a Brevo'); |
118 | 109 | return true; |
119 | 110 | } |
|
180 | 171 | </button> |
181 | 172 | </div> |
182 | 173 |
|
183 | | - <!-- Cloudflare Turnstile Container --> |
184 | 174 | <div id="turnstile-container" class="flex justify-center"></div> |
185 | 175 |
|
186 | | - <!-- Honeypot fields for spam prevention --> |
187 | 176 | <div style="position: absolute; left: -5000px;" aria-hidden="true"> |
188 | | - <!-- Original honeypot --> |
189 | 177 | <input |
190 | 178 | type="text" |
191 | 179 | name="b_6a37b9b668c1da15bcc718fa4_203574be23" |
192 | 180 | tabindex="-1" |
193 | 181 | value="" |
194 | 182 | /> |
195 | | - <!-- Additional honeypot field --> |
196 | 183 | <input type="text" name="website" tabindex="-1" value="" autocomplete="off" /> |
197 | | - <!-- Time-based validation field --> |
198 | 184 | <input type="hidden" name="form_time" value={formStartTime} /> |
199 | 185 | </div> |
200 | 186 | </div> |
|
0 commit comments