ios - Is there anyway to limit the number of character in UITextfield to 5? -


iam trying limit number of character in textfield 5 .so when trying enter 6th character not anything? possible .i saw below code not working .i have searched in google got results

    - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string {     nsuinteger newlength = [textfield.text length] + [string length] - range.length;     return (newlength > 5) ? no : yes; } 

its not working still able add more 5 character

please check delegate connection uitextfield


Comments