vprtwn / bzgformfield Goto Github PK
View Code? Open in Web Editor NEWA text field with a validity indicator
License: MIT License
A text field with a validity indicator
License: MIT License
Please guide me to handle empty field validation.
Thank you.
I've declared an alert view message ,but it's never shown:
if (![text validateMinimumLength:8]) { field.alertView.title = @"Password is too short"; return NO; } else { return YES; }
The example for setting a validation block is
[self.passwordField setTextValidationBlock:^BOOL(BZGFormField *field, NSString *text) {
if (text.length < 8) {
field.alertView.title = @"Password is too short";
return NO;
} else {
return YES;
}
}];
When I do this however, I get
May the example be outdated?
I'd like to override some values, such as DEFAULT_LEFT_INDICATOR_INACTIVE_ASPECT_RATIO
, in my app and wondering how this should be done.
For example, if this was a @Property then it could be changed easily. Please do point out if it is possible to override a #define, as you have here.
Hi,
I am trying to add BZGFormField on UITextField. However, I am getting following errors. Please guide me, how to add BZGFormField on UITextField.
---.h file -----
@protocol BZGFormFieldDelegate;
@interface AuthenticationViewController : UIViewController
@Property(strong,nonatomic) UITextField BZGFormField *emailField;
@Property(strong,nonatomic) UITextField *passwordField;
@Property(strong,nonatomic) UITextField *passwordConfirmField;
-(void)loadLoginForm;
-(void)loadRegistrationForm;
@EnD
-----.m -----
@interface AuthenticationViewController ()
@implementation AuthenticationViewController
-(void)loadLoginForm
{
NSLog(@"AuthenticationViewController loadLoginForm");
self.emailField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 230, 30)];
self.emailField.text = @"";
self.emailField.placeholder = @"Email";
self.emailField.borderStyle = UITextBorderStyleRoundedRect;
[self.emailField setTextValidationBlock:^BOOL(BZGFormField *field, NSString *text) {
// from https://github.com/benmcredmond/DHValidation/blob/master/DHValidation.m
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
if (![emailTest evaluateWithObject:text]) {
field.alertView.title = @"Invalid email address";
return NO;
} else {
return YES;
}
}];
self.emailField.delegate = self;
[self.view addSubview:self.emailField];
}
@Property(strong,nonatomic) UITextField BZGFormField *emailField;
Error :
---Interface type cannot be statically allocated
---Cannot declare variable inside @interface or @protocol
[self.emailField setTextValidationBlock:^BOOL(BZGFormField *field, NSString *text) {
Error:
---No visible @interface for 'UITextField' declares the selector 'setTextValidationBlock:'
That would be amazing!
Great Library!
Hi again! Just wanted to ask what you think about including the instance of the bzgformfield on the textvalidation block? I think it would be more convenient as opposed to having to use weakSelf to access the bzgformfield inside the validation block.
typedef BOOL (^BZGTextValidationBlock)(BZGFormField *field, NSString *text);
//Setting validation block
[self.formField setTextValidationBlock:^BOOL(BZGFormField *field, NSString *text){
//Validate text
//Add error message
field.alterView.title = @"Error Message.";
}];
Thanks!
Hi all! I plan to extend this library to support a 'required' boolean. Fields that are required will be marked differently while they are empty. If they have text then normal validation will take place.
Let me know your thoughts on this! I wil use similar UI to the invalid UI (not sure exactly what it will look like)
thanks!
Let me know if you need help making a podspec.
:)
When I try to load the class in view, I get this error.
Unknown class BZGFormField in Interface Builder file.
-[UITextField textField]: unrecognized selector sent to instance 0x99b3130
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField textField]: unrecognized selector sent to instance 0x99b3130'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.