Parsley.js: real-time validation - parsley.js

Please pardon the noob question — especially if this one is answered elsewhere.
Is it possible to configure parsley.js to validate BEFORE the form is submitted, as the user is working through the form?

Use a Parsley.js trigger with one of the jQuery javascript events, e.g.
data-parsley-trigger="focusin focusout"
Reference doc: Parsley UI Classes

Related

Best way of doing form validation in React Js

In angular2, if we want to implement form validation we will use Directives.
In React, how can we achieve this validations ???
There are several ways:
Create your own validation from scratch with plain javascript
Use browser APIs
Or you can use 3rd party plugins like 'ract-validation': https://github.com/Lesha-spr/react-validation
After struggling with too many libraries on web, here is the one I have found more helpful in entire react world. It can make developers more productive by simplifying validation job.
Try using : Formik
npm install formik --save
Why you should use :
It will saves you writing too much boggy JSX (involving annoying
properties) and dealing directly with underline handling (writing own
onBlur() onChange() event handlers) just to achieve
validation.
Formik is a small library that helps you with the 3 most annoying parts:
Getting values in and out of form state
Validation and error messages
Handling form submission
By colocating all of the above in one place, Formik will keep things organized--making testing, refactoring, and reasoning about your forms a breeze.
You should try Formik.
I am currently working with it in a project and it goes quite well.
As per their readme.md in github they say:
"Formik is a small library that helps you with the 3 most annoying parts:
Getting values in and out of form state
Validation and error messages
Handling form submission
By colocating all of the above in one place, Formik will keep things organized--making testing, refactoring, and reasoning about your forms a breeze."

Why do we use form or ng-submit in angularjs?

I am planning to have an angularjs application. We will be doing the CRUD operation using Web Api service. And these controller functions I can call from ng-click directive (I mean with out a submit)
AngularJs <-> WebApi <-> Sql Serevr => This is our stack.
We need get call to web server (to fetch files. Ex: images).
But I am wondering, will we ever need a post operation into webserver in our case?
Also, do we ever need a form,ng-form,submit,ng-submit - in our case?
Any help would be apprecicated, Thanks!
There are number of reasons outside of just submitting to use a <form> tag in your code. For one, angular wires up validation results right into the form object. If you didn't have the form, you wouldn't get that functionality.
I'd suggest taking a look at the example at the bottom of the Angular Form documentation to see why you may want to use the Form. You can see how the form.$valid and form.$error change if you clear out the textbox in the example.
https://docs.angularjs.org/api/ng/directive/form
Regarding submitting, ngSubmit will prevent the default action of a form which is usually posting the server. Similar to the validation properties that exist, there is also a form.$submitted property that will be updated to true when the form is submitted with an ng-submit. This will not happen on an ng-click.
https://docs.angularjs.org/api/ng/directive/ngSubmit
Not much different,but ng-submit would be prevent by input[required] etc. ng-click is unlimited

parsley.js with AngularJS for form validation

I'm developing application using AngularJS (using requireJS). I want to validate input fields (basically all client side validation). I thought to use Parsley.js which looks great but it doesn't work with AngularJS. HTML5 validation overrides parsley validation.
So my questions are
1) Any idea why parsley is not working with my angular app?
2) Which is best validator for angular (except angular default validation)?
I am looking into this as well. Seems that someone on SO has created a directive to make Parsley work with Angular. Click.
The best validator, as of yet, to me seems to be the built-in Angular validation. Though multi-field validation is still a pickle.
Try this
<form role="form"
ng-submit="submit(this.form, reg)"
novalidate="novalidate" ...
to prevent native browser validation

Validate forms on multiple routes in AngularJS

Disclaimer: I'm an Angular noob, this is my first project using it.
I'm currently building an app where the user is to provide lots of data in forms on multiple pages / routes. All data in all forms have to be validated before submitting.
I'm using the provided directives to set validation rules (ngPattern, ngRequired), and it's working well on each of the forms. When all fields in a single are valid, the state of the form on the current page is valid.
My problem is when trying to get the valid state for the forms on the rest of the routes. I've tried declaring the form outside ng-view,
<form name="main"><div ng-view></div></form>
and having a main form ouside outside ng-view with nested form in each routes partial. Angular is still just validating the currently displayed form. Is this possible to fix, at all? I can smell some hacky workaround here..
Here is a image for access a form validation states
More details see this

Angular Dart and form validation

Angular JS has the $pristine, $dirty, $valid, and $invalid booleans for checking the state of a form. Are there equivalents for these in Angular Dart?
Same properties will be in AngularDart, but since we are still not v1.0, we still have some missing features. This is in the works: https://github.com/angular/angular.dart/pull/372
Didn't find anything about this yet too.
EDIT
This is available and seems to work fine.

Resources