A general UITextField category for input checking.
Whatever in which way your textField was created, just add the following methods:
For configuration: - configurationWithType:
For check: - inputCheckForceCorrect:
- Download zip or clone the repo.
- Drag the folder
XCTextField
into your project. #import "UITextField+XCTextField.h"
- Have fun.
/**
some button action such as commit / login / register etc.
*/
- (void)checkButtonAction:(UIButton *)button {
for (UIView *subview in self.view.subviews) {
if ([subview isKindOfClass:[UITextField class]]) {
[(UITextField *)subview inputCheckForceCorrect:YES];
}
}
}
- (void)inputCheckForceCorrect:
param:flag
ifYES
the first incorrect textField became first responder.
XCTextFieldTypeDefault
: Style None.XCTextFieldTypeCellphone
: PRC mainland Cellphone number style.UIKeyboardTypePhonePad
.XCTextFieldTypeEmail
: Email format should be "[email protected]".UITextContentTypeEmailAddress
.XCTextFieldTypePassword
: Security text.UIKeyboardTypeASCIICapable
.XCTextFieldTypeCAPTCHA
: //@todo:XCTextFieldTypeCreditCard
: //@todo: Luhn algorithmXCTextFieldTypeIDCard
: 18 digital PRC resident ID card number verify. The last character was calculated base on "ISO 7064:1983.MOD 11-2" algorithm.