Add captcha validation error handling in script.js

A conditional block of code was added to handle the case when 'captcha_key' is not defined. This is to manage the scenario when captcha verification fails, providing an error message to the user and thus improving user experience.
This commit is contained in:
Leonid Nikitin 2023-11-25 15:12:43 +06:00
parent 23b71a09c6
commit 876fcc9e6b
Signed by: kor-elf
GPG Key ID: 604A019EB118CAC4

View File

@ -165,6 +165,11 @@
setError(errorMessage, button);
return
}
if (typeof data.captcha_key === 'undefined') {
setError('Произошла ошибка!', button);
return
}
shadow.querySelector('button.button-open-window-captcha').remove();
let captchaVerified = document.createElement('div');
captchaVerified.innerHTML = `<span class="captcha-verified">Ура!!! Проверку прошли!</span><input type="hidden" name="captcha-verified" value="${ data.captcha_key }">`;