Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation messages onblur input #197

Open
akshays-iprogrammer opened this issue Feb 24, 2017 · 2 comments
Open

Validation messages onblur input #197

akshays-iprogrammer opened this issue Feb 24, 2017 · 2 comments

Comments

@akshays-iprogrammer
Copy link

How can i validate onblur of each fileds of form? Is any provision to do that?

@RusinovAnton
Copy link

Hey, I needed that too and did some search through issues and stumbled upon this one, which can be helpful to you
#126

BinaryGeometry pushed a commit to BinaryGeometry/validate.js-1 that referenced this issue Jan 29, 2018
This commit resolves issue rickharrison#197 might be helpful as a starting point for issue rickharrison#126

Adds a public valididateOne method to the validateForm object which allows you to validate a single field manually.

/* Usage */  
var valid, field; field = $('[name="name"]).attr('name"); valid = validator.validateOne(field)
if(!valid === true){ 	/* valid === [{name, "name", message="Current error" messages="[Current error, Other errors]"}]
@BinaryGeometry
Copy link

BinaryGeometry commented Jan 29, 2018

I solved this problem here by adapting the validateForm object here

	function CheckOne( $field = $('[name="name"]), field = $field.attr('name') )
		$field.unbind('blur');
		$field.on('blur', function(e){
			var valid = validator.validateOne(field),
			if(valid === true){
				console.log(valid); // true
				this.state = 'field validates succesfully';
			} else {
                               console.log('valid'); // [{name:"field name", message="field name required"}]
				message = snwbErrorString(valid);
                                this.state = "field has errors"
			} 
		});
		return $field;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants