+ 2
controling what the user inputs in prompt
hello everybody, does any one of you knows how to prevent the user from writing a string in the prompt?
4 odpowiedzi
+ 4
#1:you have to clearly state in the prompt,that the user has to input something that isnt a string like a number.
#2:convert your prompt() from string to your required datatype like parseInt(prompt());
or you could just
<input type="number"/>
This forces a numeric keyboard on the user
+ 1
You mean, something else than numbers? Cause the user always inputs a string.
+ 1
no, I mean he have to put numbers only
+ 1
no strings