This script can be used in open-end questions to validate the field for an email address.
addPreValidationHandler("Email", () => {
const respondentEmail = getValue("Email");
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; //expression from emailregex.com
const emailValid = emailRegex.test(respondentEmail);
if(!emailValid){
//email was not valid
return 'Please enter a valid email address.';
}
});