简体   繁体   中英

allow only to enter english characters in iPhone UITextField

I want to allow user to enter only english alphabets and characters. How can i prevent user from entering other characters than english.

Check out UIKeyboardType - there is an option to support only ASCII (UIKeyboardTypeASCIICapable).

Also, there are options in the UITextFieldDelegate protocol that could allow you to selectively filter input. Take a look at:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM