Reputation: 1555
I have an editable UITextField
that takes input from the user. I need to check if the content of the text field is an integer between 10 and 100, and if it's not, display an alert telling the user what's wrong.
How might one perform the above check on a text field?
Upvotes: 1
Views: 1121
Reputation: 48398
Set up the delegate and use this method:
– textField:shouldChangeCharactersInRange:replacementString:
You can use this method to ensure that only numbers 0,1,2,3,4,5,6,7,8,9
are entered, and then pop up an alertView if [textField.text intValue] < 10 || [textField.text intValue] > 100
.
Upvotes: 4