Skip to content

Commit

Permalink
Merge pull request #172 from red-gate/email-validation-fix
Browse files Browse the repository at this point in the history
Email validation fix
  • Loading branch information
DaveConvery authored Oct 7, 2020
2 parents 892c945 + b075def commit 06355a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/forms/js/honeycomb.forms.marketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ const create = c => {
// Email validation.
if (typeof fields.Email !== 'undefined') {

// Email regex provided by https://regex101.com/r/L9Z2N0/1.
// Check that the format is {something}@{something}.{something}.
const emailRegex = /\S+@\S+\.\S+/;
// Email regex provided by https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/using_regular_expressions_to_validate_email_addresses.htm.
// Check that the format is acceptable to Salesforce (only valid salesforce characters, single @, at least one . character in domain).
const emailRegex = RegExp('^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$') ;

if (emailRegex.test(fields.Email) === false) {
if (emailRegex.test(fields.Email.toLowerCase()) === false) {
fail.isFail = true;
fail.message = 'Please enter a valid email address.';
fail.element = marketoForm.getFormElem().find('input[name="Email"]');
Expand Down

0 comments on commit 06355a2

Please sign in to comment.