Created
August 18, 2021 11:43
-
-
Save aimahdi/56f14154de5ce948c91dc3d52fa7e752 to your computer and use it in GitHub Desktop.
This code snippet will check if both email field matched or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let emailFieldOne = document.getElementById('ff_156_email'); | |
let emailFieldTwo = document.getElementById('ff_156_email_1'); | |
let submitButton = document.querySelector('.ff-btn-submit'); | |
submitButton.style.display = 'none'; | |
emailFieldTwo.insertAdjacentHTML('afterend', '<div id="customDiv" style="text-align:center; display:none; color:red;"></div>'); | |
let displayed = false; | |
let customDiv = document.getElementById('customDiv'); | |
emailFieldTwo.addEventListener('blur', function(){ | |
if(emailFieldTwo.value != emailFieldOne.value){ | |
if(!displayed){ | |
displayed = true; | |
customDiv.style.display = 'block'; | |
} | |
customDiv.innerHTML = 'Email does not matched'; | |
submitButton.style.display = 'none'; | |
}else{ | |
displayed = false; | |
customDiv.style.display = 'none'; | |
submitButton.style.display = 'block'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment