+ 1

How to limit input to numbers only?

Var A4; A4 = prompt("questions?");

28th Oct 2019, 3:57 PM
Yuriy Abramov
Yuriy Abramov - avatar
5 odpowiedzi
+ 2
Yuriy Abramov Maybe this helps, I recieved help regarding a similar question, with javascript input, making sure the input was numerical value only https://www.sololearn.com/discuss/1918538/?ref=app
28th Oct 2019, 6:47 PM
will
will - avatar
+ 3
Prompt dialog is managed by system, I don't think there's any way web code can control what keys are allowed in the prompt input box. I guess your best bet would be to try to convert the input into number, and repeat asking for input while the input ia not a valid numeric expression.
28th Oct 2019, 4:02 PM
Ipang
+ 1
Will I think it can be made easier. Assign "prompt" numerical value
28th Oct 2019, 8:11 PM
Yuriy Abramov
Yuriy Abramov - avatar
+ 1
Will. That's the decision I've come to. https://code.sololearn.com/WkJD30BW3o28/?ref=app
31st Oct 2019, 6:27 PM
Yuriy Abramov
Yuriy Abramov - avatar
0
Oh, gotcha, sorry for the confusion, I think we were working on different problems 😝
28th Oct 2019, 8:33 PM
will
will - avatar