I made a form that works only with numbers, and I want alert the user when he type letters which are invalid alert he and delete the caracther or make the input box red ..., how can I make that?
Asked
Active
Viewed 384 times
0
-
2A form with an UIWebView ? with UITextView ? could you explain more please. – Vinzius Sep 26 '10 at 13:31
-
2http://stackoverflow.com/questions/773843 – mplungjan Sep 26 '10 at 13:46
-
2possible duplicate of [iPhone UIWebview: How to force a numeric keyboard? Is it possible?](http://stackoverflow.com/questions/773843/iphone-uiwebview-how-to-force-a-numeric-keyboard-is-it-possible) – Marcel Korpel Sep 26 '10 at 13:57
-
1Don't "alert the user" with anything more than a red x or something, anything more intrusive than that will draw people away from your app – Alex Hart Sep 26 '10 at 23:27
1 Answers
0
Don't let the user type anything else, if you dont want to.
You can observe the onkeypress-Event and check the charCode. If it's not a Number, simply return false.

Dr.Molle
- 116,463
- 16
- 195
- 201