nsstring - How can I disable the decimal key on iOS keyboard -
i want disable "." key on number pad after detecting user has entered in 1 decimal point textfield.
so key enabled until 1 decimal detected in textfield.
what best way of doing this?
edit: i've implemented method below:
- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string {      if([string isequaltostring:@"."]) {         decimalcount++;     }      if(decimalcount > 1) {          [string stringbyreplacingoccurrencesofstring:@"." withstring:@""];      }      return yes; }   however, it's not replacing "." "" when decimal count greater 1. missing user can still enter new digits not decimal points??
you can't disable key. implement shouldtextfield:shouldchangecharactersinrange:replacementstring: delegate method whatever filtering need.
this needs done anyway since user using external keyboard or attempt paste text text field.
Comments
Post a Comment