Custom JS issues on workflow

Hi! I want to have a custom JS code that verifies if the email input field has a valid value before proceding with the next workflow event.

I have this function added to the custom js area but it seems that there is not return value, what am I doing wrong?

Also, is there a way to do this using Formula?

Thanks!

the js action is already the body of a function so add return isValidEmail() after the function declaration.

It’s also better to use wwLib.getFrontDocument() everytime you want to access the document, because of how weweb’s editor preview works.