Forum Discussion
Can I prevent "NaN" from appearing in numerical entry?
Is there a way to do this? Am using conditions to handle which numbers ARE allowed and to display an error if invalid numbers are entered. But can't get it to stop letters etc from being entered/processed.
Hopefully I'm having a Friday moment and missing something simple
43 Replies
- BrendaHeilmanCommunity Member
Glad you found a work around. However, wouldn't it work to set the numeric variable's default value to zero?
- DougRCommunity Member
Brenda,
The default value (that is set when you create the variable) really just determines the initial value of the variable before any other action changes it. It doesn't "restore" the variable to this value in any way after the value is changed, so the default value is only useful for setting initial conditions when the app first starts.
Doug
- PrzemysławHubisCommunity Member
Idid some research and I found JS solution:
Here is link:
https://dl.dropboxusercontent.com/u/26178433/No%20NaN%20output/story.html
And story file:
- LeaCohen-53c0f2Community Member
Another possible way to avoid nan is by using an execute JavaScript trigger after the setting the variable value:
This is the JavaScript code to run:
- MichaelHinzeCommunity Member
That's a nice one Lea. Javascript to the rescue (again)!
Thanks Lea for sharing the javascript code here with us!
- MichelleCourtCommunity Member
I'm having this issue now and it's two years down the track and 4 years from the start of this thread! Does the feature request function work? Seems crazy that this bug is still there after such a long time.
Hi Michelle,
Thanks for coming to share your need for this change and feature within Storyline, and I'm sorry it's caused you difficulty as you build your courses. Our team does keep an eye on the ELH forums and that feature request form, and uses all that information when looking at ways to update Storyline. Each feature idea is tracked thru that form and as our team looks at creating them, they focus on how many customers are impacted, what other workarounds or solutions are available, and the overall impact on the product (if it's going to change anything else about the way it works). All that information is used to determine priority and it seems this set up hasn't risen to that highest level yet. I hope that offers a bit more insight into the process and please continue to keep us in the loop on what you'd like to see in Storyline or our other products!
- MiquelCapCommunity Member
Hey Simon, I had the same problem and I tried to leave with a 0, this way, in a group it can calculate the sum of the fields.
I see that this conversation is from 5 years ago, so I hope you had solved XD, but if can be useful for other people I did this:
IF( NOT( {string} > 0) , 0 , {string})- BobbyBlake-541aCommunity Member
Hi Miquel,
Could you provide a little more insight on how to plug this into a course?
For example, the variable I'm trying to keep from being NaN is labeled "NumericEntry1"
Thanks Miquel! Never too late to pop in and assist as it could certainly help someone in the future :)
Welcome to E-Learning Heroes by the way ☺️
- MiquelCapCommunity Member
Thanks! :)
- DivyaPeruguCommunity Member
- ChrisWalshCommunity Member
@Divya,
Your requirement will be pretty complex because you will require three separate boolean IsNaN variables to separately test each of the numeric values Year, Month and Day, and then display an alternative Age value if any one of them is a NAN value.
This might be easier to do in JavaScript where theNumber.isNaN()
function is readily available. I could help but you would need to provide:- The variable names and types of the DOB and Age fields
- How you are getting the Year, Month and Day from the "Date of Birth" field
- What your triggers currently look like.
Related Content
- 2 months ago
- 2 years ago
- 4 months ago
- 11 months ago