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?
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);
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.
I just wanted to pop in and welcome you to E-Learning Heroes and let you know that you may want to reach out via PM for follow up as I'm not sure they are subscribed to the thread
sorry for late reply. I have added javascript validation code directly in .story file. please check updated attached story file in http environment only. and plz let me know if it will be helpful for you.
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!
11 Replies
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
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!
Hi Joe!
I just wanted to pop in and welcome you to E-Learning Heroes and let you know that you may want to reach out via PM for follow up as I'm not sure they are subscribed to the thread
Hi Joe,
sorry for late reply. I have added javascript validation code directly in .story file. please check updated attached story file in http environment only. and plz let me know if it will be helpful for you.
Thanks,
Pranali
Hi Joe and Pranali,
Sorry for late replay. Even I tried to solve that problem by using the javascript code provided by Pranali on august 11 but it didn't work.
@pranali, I will try with your new code and hope it will work.
Thanks,
Vijay
Hi Pranali,
Thanks for your storyline file. It is working fine. Really it is helpful to us.
Thanks,
Vijay
Thanks for update. happy to help you Vijay
Love great community team work Thanks for sharing!
Thanks, Pranali, for your code sample! I only had to tweak the email variable name to reflect the variable I'm using. The validation works great!!!
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!
Very neat, Adam! Thanks for circling back to share this handy pro-tip. 🌟
This discussion is closed. You can start a new discussion or contact Articulate Support.