-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (49 loc) · 1.83 KB
/
script.js
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
captcha.initiateCaptcha('captchaContainer', { hoverColor: "green" });
addEventListeners();
function submitForm() {
if (validateCaptcha()) {
alert('Valid Captcha');
} else {
alert('Invalid Captcha');
}
event.preventDefault();
}
function captchaTextType(event) {
const selectedValue = event.target.value;
captcha.initiateCaptcha('captchaContainer', { equation: selectedValue === 'Equation' });
}
function captchaLineType(event) {
const selectedValue = event.target.value;
captcha.initiateCaptcha('captchaContainer', { grid: selectedValue === 'Grid' });
}
function captchaFeatures(event) {
const selectedValue = event.target.value;
if (selectedValue === 'Audio') {
captcha.initiateCaptcha('captchaContainer', { audio: event.target.checked });
}
if (selectedValue === 'Reload') {
captcha.initiateCaptcha('captchaContainer', { reload: event.target.checked });
}
}
function addEventListeners() {
const radioCaptchaType = document.querySelectorAll('input[name="captchaType"]');
for (const radioButton of radioCaptchaType) {
radioButton.addEventListener('change', captchaTextType);
}
const radioCaptchaLineType = document.querySelectorAll('input[name="captchaLine"]');
for (const radioButton of radioCaptchaLineType) {
radioButton.addEventListener('change', captchaLineType);
}
const radioCaptchaFeatures = document.querySelectorAll('input[name="captchaFeatures"]');
for (const radioButton of radioCaptchaFeatures) {
radioButton.addEventListener('change', captchaFeatures);
}
document.querySelector("#myForm").addEventListener("submit", function (e) {
if (captcha.validateCaptcha()) {
alert('Valid Captcha');
} else {
alert('Invalid Captcha');
}
e.preventDefault();
});
}