-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
# XCTextField | ||
|
||
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:` | ||
|
||
## Usage: | ||
|
||
1. Download zip or clone the repo. | ||
2. Drag the folder `XCTextField` into your project. | ||
3. `#import "UITextField+XCTextField.h"` | ||
4. Have fun. | ||
|
||
## Sample Code: | ||
|
||
```objc | ||
/** | ||
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` if `YES` the first incorrect textField became first responder. | ||
## Paraphrase: | ||
|
||
- `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 algorithm | ||
- `XCTextFieldTypeIDCard`: 18 digital PRC resident ID card number verify. The last character was calculated base on "ISO 7064:1983.MOD 11-2" algorithm. | ||
|