Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email validation fix #172

Merged
merged 4 commits into from
Oct 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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