CCValidatedTextField 1.1.1

CCValidatedTextField 1.1.1

TestsTested
LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total2,266
Week0
Month0

Installs

Apps44
Test Targets3
powered by Segment

GitHub

Stars35
Watchers3
Forks4
Issues0
Contributors2
Pull Requests1

Code

Files2
LOCLines of Code 121


  • By
  • Chris Chares

Add real-time validation to UITextField with blocks

sample

Easy block based methods with the opportunity for full customization

NSString *emailPattern = @"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$";
_emailField.validationBlock = ^(NSString *text) {
  return ([text rangeOfString:emailPattern options:NSRegularExpressionSearch].location != NSNotFound );
};
_emailField.postValidationBlock = ^(BOOL valid){
  if ( valid ) {
    _emailStatus.image = [UIImage imageNamed:@"valid"];
  } else {
    _emailStatus.image = [UIImage imageNamed:@"invalid"];
  }
};

If you want to check if a textfield is currently valid (before submitting a form, for example), simply check CCTextField's .valid property

BOOL fieldIsInValidState = _emailField.valid;

Installation

Cocoapods

pod 'CCValidatedTextField', '~> 1.0.1'