Reputation: 1934
I have a textfield that I want to set a limit, not the digit value, but numerical (numeric keypad). For example, if my limit is 59 and I press 6, all other numbers you should disable. Do you think it possible?
Thanks a lot!
Upvotes: 1
Views: 123
Reputation: 53960
Not possible to disable keys on the keyboard. But...
Assuming you got a numeric keyboard, listen for the keyboard events, and delete data from the text field when the value reaches a value higher than 59.
Also provides user feedback, like a device vibration, so the user will know a wrong value was entered.
Upvotes: 1
Reputation: 51374
No. Its not possible to disable the keys in the keyboard. You have to write your logic to prevent certain text to be entered in the text field.
You would probably have to write your code inside textField:shouldChangeCharacterInRange:
method.
Upvotes: 1