Foro de discusión Foro de discusión

Atrás

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

Alternar
How to constrain input to numbers only on an text input box?
text input regular expression number input
Respuesta
26/10/20 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 Votos)

RE: How to constrain input to numbers only on an text input box?
Respuesta
26/10/20 20:18 en respuesta a 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!

archivos adjuntos:

Adjunto

0 (0 Votos)