Best answer

JS Code Regex to verify Email

  • 22 September 2021
  • 4 replies


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](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/

     return {rv: myEmail}
  else return {rv: ""}


Best answer by Troy Tessalone 22 September 2021, 16:05

View original

4 replies

Userlevel 7
Badge +11

Hi @CLA 

Check out this help article:

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)



Userlevel 7
Badge +11

Hi @CLA 

Feedback/Suggestions/Feature Requests can be submitted via Zapier Support:

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.