help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

help!

how to make sure user only put a number instead of letter in a prompt box .. example if he/she put a letter in a prompt box and click "ok", there's an alert box would display "error" or something like that.

5th Apr 2017, 5:03 AM
miracle
2 Answers
+ 2
Check every character of the string (using a for loop etc,). If one non number occurs, alert an error.
5th Apr 2017, 11:11 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
in android we can say that wich parameter we need just by a click on "textnumber" In other situation we can separate it to characters and use "switch". then check if it is a number from 0-9
5th Apr 2017, 5:39 AM
Mehran Ehsandoost
Mehran Ehsandoost - avatar