JavaScript Email Validation + Storyline Learner Feedback

Oct 14, 2022

This is one for the community, as I know Articulate isn't the support desk for JavaScript. This isn't really about the JS. It's about having a Storyline project do something based on the outcome of some JS.

I have a project where the learner is expected to enter their email address in a form field and click a button. I have a JS trigger attached to that button which performs email validation on the address entered and then, if it passes, calls an API and hands off that email address (along with a few other things), so the API can email a certificate of completion. 

All of that works fine. I'm just adding some finishing UX touches. What I'd like to do is give the learner some feedback if the regular expression test fails. For example, I could display some a layer that says "Please enter a valid email address." Any thoughts on how that might work? Maybe I could create a Storyline variable (e.g. varValidEmail) and SetVar(), in the JS, to pass along the status of the regular expression test?

Did I just solve my own problem by having to write this out?  Do you have a better way to solve it? Any advice is welcome. 

5 Replies
Math Notermans

Often writing down a problem... clarifies it for yourself and the solution is in reach ;-)
Happens to me all the time too.

A few things i tend to do in cases like this.
I name my variables so in 1 glimpse i can see what it is, and what type it is...
So for a Boolean True/False that shows whether the email is valid..
i would use...

isEmailValid

Setting that either to True or False... and on a change of that variable you can show your SlideLayer.

A Variable of type string would be:
emailValidStr

And ofcourse if i use Numerics it would be:
emailValidNum

James Martin

Hi Ali, 

The API is a script running on AWS that one of our developers put together. I don't know much about the internals. I just know how to call it and what parameters I need to hand it. I'm sure there are other ones out there, but this script had already been developed for a different purpose. I just found a new way to leverage it. 

Cheers,

James