Decimal numbers

Hi, 

Is there any way to prevent users from entering decimal numbers and words/alphabets in the text field? I would like them to enter numbers only. And the text field has to be blank each time it is reset or revisit. I don't want to see a '0' (zero) when it is reset or revisit - this is why I didn't use a numeric entry field for my project.

Appreciate your help.

Thanks.

6 Replies
Matthew Bibby

Hi Megan,

"Is there any way to prevent users from entering decimal numbers..." Have you tried this approach?

"And the text field has to be blank each time it is reset or revisit" The text entry fields will show whatever the value of the associated variable is. If you want them to be blank when revisited, you'll need to add a trigger to the slide that changes the variable to be blank (or equal to 0 if using a number variable). You may also need to adjust the When revisiting... option in the slide properties.

"I don't want to see a '0' (zero) when it is reset or revisit" there are ways to work around this (e.g. see here) but no need to go down that path if text entry fields are working for you. 

Megan Yeo

Hi Matthew

Thanks for your help!

The approach works well! However, I encountered another issue when I added this new trigger. The 'Submit' button remains disabled until the user enter a number in the text field. Once the user enters a number in the text field, the Submit button becomes Normal. In this case, when the user enters a decimal number, an error message shows up, and at the same time, the Submit button becomes Normal. I have tried to disable the Submit button if the user enters any decmial number using the below trigger but it is not working:

Action: Change state of

On Object: Submit button

To State: Normal

When: Variable changes

Variable: TextEntry

On Condition: TextEntry not equal to '.'

Besides that, is there any way to prevent the users from entering alphabets/words?

Thanks once again!

Nicole Legault

Hi Megan!

When you insert a Numeric text entry field, the field itself will be blank and have nothing in it, by default. It does not have a 0 (zero) in it. Its empty. Also, when you use a numeric text entry field you can only enter numbers, no text. For these reasons, I would suggest you use a numeric text entry field instead. 

Hope this helps! 

Megan Yeo

Thanks for your suggestion Nicole.

I actually used the Numeric text entry field earlier. And it does show a zero when I used it and I can't seem to remove it. That is why I used the text entry field in the end. I'm using SL3. Perhaps there is a different way that you use the Numeric entry field? Can you please show me how it is done?

Thanks.