I applied the code as below. however, somehow it stopped at the line "confirmEmail.parentNode.appendChild(err);"
alert message after this line does not show up. Not sure why
MsCrmMkt.MsCrmFormLoader.on('formSubmit', function (event) {
// sample validation - check if
var email = document.getElementById('7f685ebb-7c54-4cff-a1bc-772562d25c38').value;
var confirmEmail = document.getElementById('48aa37a4-e4c2-ea11-a812-000d3a0c8127').value;
var err = document.createElement("div");
/** Optional, you can also predefine CSS in your marketing page.(By giving a class name to error message element.) */
var style = "";
style += "border: 1px solid #F2F2F2; ";
style += "border-radius: 5px; ";
style += "background: #fff; ";
style += "color: red; ";
style += "padding: 3px; ";
style += "font-weight: 400; ";
style += "position: relative; ";
style += "z-index: 10000; ";
style += "bottom: 12px";
err.setAttribute("style", style);
if (email !== confirmEmail) {
event.preventDefault();
alert(" before confirm===");
confirmEmail.parentNode.appendChild(err);
alert(confirmEmail + "====after confirmEmail");
err.innerText = 'Both email and confirm email should be the same';
} else {
alert(confirmEmail + "====else confirmEmail");
confirmEmail.parentNode.lastChild.remove();
}
});