Pricing
VisionAI Workplace Solutions are available at affordable subscription pricing to enhance your workplace safety.
jQuery(document).ready(function($) {
function attachEmailValidation() {
var emailInput = document.querySelector('input[name="email-1"]');
if (emailInput) {
function validateEmail() {
var emailValue = emailInput.value;
var emailDomain = emailValue.split('@')[1] || ''; // Handle case with no '@'
// Check if the domain is gmail.com
if (emailDomain === 'gmail.com') {
var errorSpan = document.getElementById('email-error');
if (!errorSpan) {
// Create the error span
errorSpan = document.createElement('span');
errorSpan.id = 'email-error';
errorSpan.style.color = 'red';
errorSpan.style.display = 'inline';
errorSpan.textContent = 'Gmail addresses are not allowed.';
emailInput.parentNode.appendChild(errorSpan);
}
emailInput.setCustomValidity('Gmail addresses are not allowed.');
} else {
// Remove the error span if it exists
var errorSpan = document.getElementById('email-error');
if (errorSpan) {
errorSpan.remove();
}
emailInput.setCustomValidity('');
}
}
// Attach event listener for keyup events
emailInput.addEventListener('keyup', validateEmail);
} else {
console.error('Email input field not found');
}
}
function onElementorFrontendInit() {
// Add event listener to detect step changes when next button is clicked
var nextButtons = document.querySelectorAll('.forminator-button-next');
nextButtons.forEach(function(button) {
button.addEventListener('click', function() {
console.log('click');
setTimeout(attachEmailValidation, 500); // Delay to allow the DOM to update
});
});
// Initial call in case the email field is already present
attachEmailValidation();
}
// Use Elementor's frontend hook to ensure scripts run at the right time
$(window).on('elementor/frontend/init', onElementorFrontendInit);
});