Lisää laskutoimituscaptcha tarjouspyyntölomakkeeseen
Satunnainen yhteenlaskukysymys (esim. "Paljonko on 3 + 5?") tarkistetaan sekä client- että serverpuolella. Vain sähköposti on nyt pakollinen kenttä. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,8 +65,8 @@
|
||||
<!-- Yhteystiedot -->
|
||||
<div class="form-section-title">Yhteystiedot</div>
|
||||
<div class="form-group">
|
||||
<label for="name">Nimi *</label>
|
||||
<input type="text" id="name" name="name" required>
|
||||
<label for="name">Nimi</label>
|
||||
<input type="text" id="name" name="name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="company">Yritys</label>
|
||||
@@ -191,6 +191,14 @@
|
||||
<textarea id="message" name="message" rows="4" placeholder="Kerro lisää tarpeistasi: tehovaatimukset, aikataulu, erityistoiveet..."></textarea>
|
||||
</div>
|
||||
|
||||
<!-- Captcha -->
|
||||
<div class="form-section-title">Varmistus</div>
|
||||
<div class="form-group">
|
||||
<label for="captcha" id="captcha-label"></label>
|
||||
<input type="text" id="captcha" name="captcha" required autocomplete="off" inputmode="numeric" placeholder="Vastaus">
|
||||
<input type="hidden" id="captcha-answer" name="captcha_answer">
|
||||
</div>
|
||||
|
||||
<!-- Honeypot -->
|
||||
<div style="display:none" aria-hidden="true">
|
||||
<input type="text" name="website" tabindex="-1" autocomplete="off">
|
||||
@@ -282,6 +290,19 @@
|
||||
|
||||
<script src="script.js"></script>
|
||||
<script>
|
||||
// Captcha
|
||||
(function() {
|
||||
function generateCaptcha() {
|
||||
const a = Math.floor(Math.random() * 10) + 1;
|
||||
const b = Math.floor(Math.random() * 10) + 1;
|
||||
const answer = a + b;
|
||||
document.getElementById('captcha-label').textContent = 'Paljonko on ' + a + ' + ' + b + '? *';
|
||||
document.getElementById('captcha-answer').value = answer;
|
||||
}
|
||||
generateCaptcha();
|
||||
window._refreshCaptcha = generateCaptcha;
|
||||
})();
|
||||
|
||||
// Price Calculator
|
||||
(function() {
|
||||
const form = document.getElementById('quote-form');
|
||||
@@ -410,6 +431,17 @@
|
||||
const honeypot = form.querySelector('[name="website"]');
|
||||
if (honeypot && honeypot.value) return;
|
||||
|
||||
// Captcha check
|
||||
const captchaInput = document.getElementById('captcha').value.trim();
|
||||
const captchaAnswer = document.getElementById('captcha-answer').value;
|
||||
if (captchaInput !== captchaAnswer) {
|
||||
status.textContent = 'Väärä vastaus varmistuskysymykseen.';
|
||||
status.className = 'form-status form-status-error';
|
||||
window._refreshCaptcha();
|
||||
document.getElementById('captcha').value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const submitBtn = form.querySelector('.btn-submit');
|
||||
submitBtn.disabled = true;
|
||||
status.textContent = 'Lähetetään...';
|
||||
@@ -431,6 +463,7 @@
|
||||
status.className = 'form-status form-status-success';
|
||||
form.reset();
|
||||
calculate();
|
||||
window._refreshCaptcha();
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
|
||||
Reference in New Issue
Block a user