diff --git a/src/js/models/metadata/eml211/EMLParty.js b/src/js/models/metadata/eml211/EMLParty.js index 1722565a4..70ad47882 100644 --- a/src/js/models/metadata/eml211/EMLParty.js +++ b/src/js/models/metadata/eml211/EMLParty.js @@ -886,7 +886,7 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function ( this.get("type") == "associatedParty" ? this.get("roles") : [this.get("type")]; - for (role of roles) { + for (let role of roles) { let requiredFields = MetacatUI.appModel.get( "emlEditorRequiredFields_EMLParty", )[role]; @@ -899,6 +899,17 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function ( }); } + // If there is an email address, validate it + const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; + const email = this.get("email"); + if (email?.length) { + email.forEach((emailAddress) => { + if (!emailAddress.match(emailRegex)) { + errors.email = "Provide a valid email address."; + } + }); + } + return Object.keys(errors)?.length ? errors : false; }, diff --git a/src/js/templates/metadata/EMLParty.html b/src/js/templates/metadata/EMLParty.html index 318247e09..a545f3229 100644 --- a/src/js/templates/metadata/EMLParty.html +++ b/src/js/templates/metadata/EMLParty.html @@ -20,7 +20,8 @@