Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dan-donica
Created July 19, 2023 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dan-donica/826c74b6ca24faaf8927226f433d11f4 to your computer and use it in GitHub Desktop.
Save dan-donica/826c74b6ca24faaf8927226f433d11f4 to your computer and use it in GitHub Desktop.
HC || Business Email Validation
<!-- Begin "Business Email Validation" || Help center -->
<!-- Insert in Settings->Javascript->Footer -->
<!-- CS:20200722-02-0 -->
<script>
var label = 'Email';
var standardEmail = /^(?!.+@(gmail|google|yahoo|outlook|hotmail|msn)\..+)(.+@.+\..+)$/;
var errorMessage = 'field: Please enter your business email address.';
document.querySelector("input[name='" + label + "']").addEventListener("input", function(e){
e.target.value = e.target.value.toLowerCase();
});
window.__custom_form_validations = [
{
fieldName: label,
validationFn: function (input) {
return {
isValid: standardEmail.test(input.value),
message: window._Translate.get(errorMessage),
};
},
},
];
</script>
<!-- END code that excludes standard email domains -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment