I've been working on this function, but I'm having trouble getting it to run properly. None of my console.log messages are showing up in the console. This function is supposed to validate emails upon submission, but only for a specific domain.
function checkEmailValidity() {
console.log('First message')
var emailInput = document.querySelectorAll('t186__input');
console.log('Input checked');
var submitButton = document.querySelectorAll('t-submit');
console.log('Submit button checked');
submitButton.addEventListener('click', function(e) {
e.preventDefault();
console.log('Click event detected');
if (emailInput.val().indexOf('@rbc.com') !== -1) {
return true;
console.log('Validation successful');
} else {
alert("You have entered an invalid email address");
return false;
}
});
}
<div class="t186__wrapper">
<div class="t186__blockinput">
<input type="text" name="EMAIL" class="t186__input t-input js-tilda-rule" value="" placeholder="Your E-mail" data-tilda-rule="email" style="color:#000000; border:1px solid #000000;" />
</div>
<div class="t186__blockbutton">
<button type="submit" class="t-submit" style="color:#ffffff;background-color:#000000;">Subscribe</button>
</div>
</div>