Validate textfield with special character
cocoa-touch, ios4, iphone, objective-c
Solution
Try like below it will help you.It will accept only letters
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//For avoiding user to enter non digital number..
if([[string stringByTrimmingCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] isEqualToString:@""])
{
return NO;
}
else
{
return YES;
}
}
Problem
In my app. I want to validate textfield with Special characters, Ex. if user press the ? from keypad than user not able to enter the ? in Textfield, Please any one suggest, How can i do that?