#google-captcha');
for (var i = 0; i < bodyCaptchas.length; i++) {
// Verify it's a FormAssembly captcha by checking for specific structure
if (bodyCaptchas[i].querySelector('.captcha .oneField .g-recaptcha')) {
faCaptcha = bodyCaptchas[i];
break;
}
}
}
if (faCaptcha) {
if (faCaptcha.parentNode) {
faCaptcha.parentNode.removeChild(faCaptcha);
}
}
// Now create a new captcha container
var captchaContainer = document.createElement('div');
captchaContainer.id = 'google-captcha';
var captchaDiv = document.createElement('div');
captchaDiv.className = 'captcha';
var oneFieldDiv = document.createElement('div');
oneFieldDiv.className = 'oneField';
var recaptchaElement = document.createElement('div');
recaptchaElement.id = 'g-recaptcha-render-div';
recaptchaElement.className = 'g-recaptcha';
var errorDiv = document.createElement('div');
errorDiv.className = 'g-captcha-error';
var helpDiv = document.createElement('div');
helpDiv.className = 'captchaHelp';
helpDiv.innerHTML = 'reCAPTCHA helps prevent automated form spam.
';
var disabledDiv = document.createElement('div');
disabledDiv.id = 'disabled-explanation';
disabledDiv.className = 'captchaHelp';
disabledDiv.style.display = 'block';
disabledDiv.innerHTML = 'The submit button will be disabled until you complete the CAPTCHA.';
oneFieldDiv.appendChild(recaptchaElement);
oneFieldDiv.appendChild(errorDiv);
oneFieldDiv.appendChild(document.createElement('br'));
captchaDiv.appendChild(oneFieldDiv);
captchaDiv.appendChild(helpDiv);
captchaDiv.appendChild(disabledDiv);
captchaContainer.appendChild(document.createElement('br'));
captchaContainer.appendChild(captchaDiv);
if (submitButton && submitButton.parentNode) {
submitButton.parentNode.insertBefore(captchaContainer, submitButton);
} else {
// Fallback: append to body if submit button not found.
document.body.appendChild(captchaContainer);
}
} finally {
window.isCreatingCaptcha = false;
}
if (RECAPTCHA_SITEKEY && typeof grecaptcha !== 'undefined' && grecaptcha.enterprise && grecaptcha.enterprise.render) {
grecaptcha.enterprise.render('g-recaptcha-render-div', {
sitekey: RECAPTCHA_SITEKEY,
theme: 'light',
size: 'normal',
callback: 'enableSubmitButton',
'expired-callback': 'disableSubmitButton'
});
}
window.hasCaptchaRendered = true;
var oldRecaptchaCheck = parseInt('1');
if (oldRecaptchaCheck === -1) {
var standardCaptcha = document.getElementById("tfa_captcha_text");
standardCaptcha = standardCaptcha.parentNode.parentNode.parentNode;
standardCaptcha.parentNode.removeChild(standardCaptcha);
}
if (!wFORMS.instances['paging']) {
document.getElementById("g-recaptcha-render-div").parentNode.parentNode.parentNode.style.display = "block";
//document.getElementById("g-recaptcha-render-div").parentNode.parentNode.parentNode.removeAttribute("hidden");
}
document.getElementById("g-recaptcha-render-div").getAttributeNode('id').value = 'tfa_captcha_text';
var captchaError = '';
if (captchaError == '1') {
var errMsgText = 'The CAPTCHA was not completed successfully.';
var errMsgDiv = document.createElement('div');
errMsgDiv.id = "tfa_captcha_text-E";
errMsgDiv.className = "err errMsg";
errMsgDiv.innerText = errMsgText;
var loc = document.querySelector('.g-captcha-error');
loc.insertBefore(errMsgDiv, loc.childNodes[0]);
/* See wFORMS.behaviors.paging.applyTo for origin of this code */
if (wFORMS.instances['paging']) {
var b = wFORMS.instances['paging'][0];
var pp = base2.DOM.Element.querySelector(document, wFORMS.behaviors.paging.CAPTCHA_ERROR);
if (pp) {
var lastPage = 1;
for (var i = 1; i < 100; i++) {
if (b.behavior.isLastPageIndex(i)) {
lastPage = i;
break;
}
}
b.jumpTo(lastPage);
}
}
}
}
}