I want to disable or also I have does not give permission开发者_如何学编程 entering the alpha, alpha numeric and special character in UITextField I mean when user enter the alpha and special character in text box then I want to quickly message box pop-up to showing him u only have use 0, 1-9 digit. Please give me any source code and tutorials on it.
Call setKeyboardType:
on your UITextField, and pass one of the UIKeyboardType
constants. I’m not sure which one fits your description.
- (void)awakeFromNib
{
[textField setKeyboardType:UIKeyboardTypeNumberPad];
}
Take a look at the UITextFieldDelegate protocol. There’s a method called textField:shouldChangeCharactersInRange:replacementString:
where you can validate the replacement string and return NO
if it falls into one of the disallowed sets. As for the validation itself, see the method rangeOfCharacterFromSet:
of the NSString class and the NSCharacterSet class.
精彩评论