ios - How to make a UITextField disabled for deleting the custom number -
i have app, has login form! , users logging in telephone number. cell phone number starts country code , it's possible type +7 or 8.. need strict field, except +7 sign. how customize uitextfield user change rest of field?? mean, need text field have text property filled +7 number , user won't able delete it, add number. hope, it's understandable ))) in advance.
you should implement textfield:shouldchangecharactersinrange:replacementstring:
method of uitextfielddelegate
, return no
first 2 characters (the prefix "+7"
).
something like
- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { return !nsequalranges(range, (nsrange){0,2}); }
this prevent first 2 characters in text field modified @ all.
Comments
Post a Comment