掲示板 掲示板

戻る

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
答え
20/10/26 17:59
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/10/26 20:18 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 投票)