Validation for the textentry field

Aug 10, 2014

Hi all,

Is there any way to validate the textfield such as user must enter email only (for example he must enter name@domain.com, name@domain.in, name@domain.co.in etc...). If user doesn't enter the email correctly then i want to show an alert. Is it possible?

11 Replies
Pranali Chaudhari

Hi Vijay,

yes, it is possible by using javascript in storyline. I have attached sample file for this, hope it will help for you. please add below code in user.js file of storyline publish output.

code for javascript:

Function ValidateEmail()

{

var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var player = GetPlayer();
var email=player.GetVar("Emailentry");

var isValidate=false;
if (reg.test(email))
{
var isValidate=true;
}
else
{
var isValidate=false;
}
player.SetVar("isValidate",isValidate);

}

Regards,

Pranali

Joe P

Hi Pranali and Vijay,

I was wondering if this solution had solved your problem with the email validation, as I am designing a similar slide and running into the same situation of not knowing how to develop a text entry box to be forced to contain a @ symbol.

I can't get Pranali's story file to work, even after adding the code into the user.js file. I know it will have to execute some javascript.

Any help would be appreciated!

Adam McCash

Not sure if many people are using this, but thought I'd follow-up with a quick note.  When using the storyline demo Pranali provided, I did have two switch two triggers to get it to function properly.

For the Text Entry box, there are two triggers.  Be sure the trigger to set the "txtEmailEntry" is listed *before* the trigger to execute the Javascript that validates the email address.  Otherwise, the first email address will always cause an invalid email response (since it doesn't know what the email address is when running the Javascript code).  

Hope this helps anyone else who may be struggling with getting this to work.  Once you have those triggers in the right order, it works great!!  This is awesome and exactly what I needed.  

Thank you (all these years later) for creating this Pranali!

This discussion is closed. You can start a new discussion or contact Articulate Support.