Skip to main content

Hi,

Does anyone have some JavaScript that can verify a valid email address in the code module?

I have the following - but I cant find the right way of performing the test, I’m not a programmer but I cant see why this isn't working? Any help much appreciated. At the moment it seems to pass everything through.

 

if(inputData.eMail == null){
 return{ rv: ""}
}
else {
  const myEmail = inputData.eMail.replace(/\s+/g, '') // remove all whitespace from string
  const RegExpConst =  /(?:=a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.-a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*|"(?:+\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:)a-z0-9](?:za-z0-9-]*-a-z0-9])?\.)+9a-z0-9](?:za-z0-9-]*-a-z0-9])?|\0(?:(?:25(0-5]|250-4]]0-9]|401]?90-9]10-9]?)\.){3}(?:25{0-5]|250-4]]0-9]|401]?90-9]10-9]?|]a-z0-9-]*-a-z0-9]:(?:0\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/

  if(myEmail.matchAll(RegExpConst)){
     return {rv: myEmail}
  }
  else return {rv: ""}
}
 

Hi @CLA 

Check out this help article: https://www.w3resource.com/javascript/form/email-validation.php

Some GSearches on the topic should provide you with the proper JavaScript code to use.


Thanks Troy,

I managed to work it out.

Could I suggest that in the help link from the code module that Zapier also add a link to a syntax/cook book library for the node 10 JS or which ever is the “RIGHT” version of JavaScript to follow. In the end I just had to randomly try different things till something worked. This is not efficient even if you are as bad a programmer as I am ;o)

Regards,

 


Hi @CLA 

Feedback/Suggestions/Feature Requests can be submitted via Zapier Support: https://zapier.com/app/get-help


I would be happy to feed this back - however there is no mention of the words “feedback”, “suggestions” or “Feature requests” on the linked page. Could you be more specific - as you can see I’m pretty dense - and although happy to try and provide honest feedback I would prefer that process to not be a game of hide and seek.

thanks