Hi Jon,
I have gone back and forth on this solution and still don't have a result that forces the user to enter our university email format before submitting. At the moment whenever the users enters a non university email I post our own warning in the same format as the Catalog error and attempt to force focus back to the email text box as follows:
//create email error message and don't display it
var emailInput = document.evaluate('//*[@id="registration"]/form/div[4]/span[2]/span/label/span/span/span[2]/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var emailInputFirstChild = emailInput.firstChild;
emailErrorMsg =
"<span style='color: #EE0612; font-family: LatoWeb, Lato, \"Helvetica Neue\", Helvetica, Arial, sans-serif; font-weight: 400; font-size: 0.75rem; line-height: 1.4; display: none' id='rmitEmailErrorMessage'><br>Name based Email is required.</span>";
emailInput.insertAdjacentHTML('afterend', emailErrorMsg);
//Setup on focus events for the other controls to have them display a message and return focus to the
//email field on error
var eNumberStaffInputFirstChild = document.evaluate('//*[@id="registration"]/form/div[4]/span[3]/span/label/span/span[1]/span[2]/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.firstChild;
//I have tried this by itself and together with the blur call
eNumberStaffInputFirstChild.addEventListener("focus", function () {
checkEmailFormat(emailInput, emailInputFirstChild.value.toUpperCase().trim());
});
emailInputFirstChild.addEventListener("blur", function () {
checkEmailFormat(emailInput, emailInputFirstChild.value.toUpperCase().trim());
});
.....
function checkEmailFormat(theTextInput, eString) {
if(eString fails validation) {
// displayRMTIEmailErrorMessage
emailTextElement.firstChild.style.borderColor = "#EE0612";
var rmitEmailErrorMsg = document.getElementById("rmitEmailErrorMessage");
if (rmitEmailErrorMsg!=null)
rmitEmailErrorMsg.style.display = "block";
event.stopPropagation();
event.preventDefault();
setTimeout(function () { theTextInput.focus(); }, 50);
} All attempts to force focus back to the text box have failed. I suspect REACT is taking over and invalidating the calls. Do you have a suggestion to get around this problem?
Thanks,
Simon
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.