I have started putting some validation in the text fields. There must be an easier way than writing every possible check.
There are two things I’d like to do:
- I need the user to type in a year. I have set the keyboard to numeric. how can I limit the length to max of 4, check to see if it is in the past < than current year, etc…
- Just want to limit the length of another entry to 7 characters
you would use the UITextField delegate
set the delegate on the uitextfield and then implement these methods into your class
then check whenever that updates if the string will be less than or equal to 4 characters and do any other sort of checks as to what will be changed nd return
YESif you want to allow it andNOif not