ipad - How to accept numbers in input field only in iphone app -


i making app want when user inputs data whatever user enter if enters not take input , show nothing in textfield , if enter number should accept.

following code should you, not allow other text entered in text field other numbers.

- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string {     static nscharacterset *charset = nil;     if(!charset) {     charset = [[[nscharacterset charactersetwithcharactersinstring:@"0123456789"] invertedset] retain];     }     nsrange strlocation = [string rangeofcharacterfromset:charset];     return (strlocation.location == nsnotfound); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -