לוחות מודעות לוחות מודעות

חזרה

How to constrain input to numbers only on an text input box?

מתג
How to constrain input to numbers only on an text input box?
text input regular expression number input
תשובה
17:59 26/10/20
Is there any way to restrict user input to numbers only on a text input object?

Please show me how to do that.
0 (0 הצבעות)

RE: How to constrain input to numbers only on an text input box?
תשובה
20:18 26/10/20 כתגובה ל-D Singh
Hi Daljit,
Normally you would use a Number Input object to collect numerical entries from learners. However, if you don't like the default "0", or you have another reason not to use the Number Input object, you can instead use a Text Input object, and an action that removes any non-numeric characters. But you won't get the nice formatting options (e.g., $1,000). If you want to do that, here's how - https://www.screencast.com/t/wYaWtYhd

Regex is extremely powerful for text manipulation, and you can look up all sorts of shortcuts for that. "\W" is one that I use for taking "The quick brown fox is #rabid!!!" and making it web safe, "The_quick_brown_fox_is__rabid___".

Hope that helps!

קבצים מצורפים:

קובץ מצורף

0 (0 הצבעות)