how to validate dynamically added controls in react js - reactjs

I'm new to react framework and I'm creating the components dynamically (textbox,checkbox & select) and I would like to validate it before submitting the
Form. Can anyone suggest ideas?

React Forms might help you with front end form validation.

There's also Formsy-React:
https://github.com/christianalfoni/formsy-react
It lets you specify your form validation logic without using JSX, which is a plus if you want framework-neutral validation.

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."

Parsley.js: real-time validation

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

One page wizard using angular formly

I'm creating form using angular formly with more than 50 fields and i have displayed fields using Advance layout. (link)
Now the form is so big and i want to divide it in small parts.
How can i
achieve one page wizard (eg- Sample Pattern ) using angular formly?
Or is there any other best way to show such big form in user friendly manner using angular formly? Please Suggest.
Another issue that i'm facing is most of the fields in the form are select field and data in this select field is coming from server. So the form is taking some time to load. How can i reduce the loading time of form?
You can easily use
http://angular-formly.com/#/example/bootstrap-specific/advanced-layout
and break up the form into a step manner for user friendly form.
I don't think formly-form takes time in rendering (negligible). You might need to tweak your server api to return data soon.

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

Cake PHP Form Flexibilty

I want to replicate the html that the cakephp form helper creates, so i can add to it and integrate it into my bootstrap front end. Basically the cakephp form helper isnt generating the html I need.
Someone else built the app using cake forms, and I dont want to rewrite the backend.
I thought it would simply be a case of including the correct input names, form classes etc, and building upon it. It seems however that even an exact copy/paste of the form html doesnt trigger the cakephp form errors.
It sends identical headers to cake,
http://pastebin.com/JZyCk6cv
so I can only assume that the cakephp form helper does some jiggery pokery when its constructed in the template, in order to trigger validation errors?
I think the best solution is to create a custom CakePHP-Helper. If you're using twitter-bootstrap i recommend this Helper, packed as a plugin:
https://github.com/loadsys/twitter-bootstrap-helper
Form validation should work, as it uses CakePHP's core form-helper to create inputs and labels.
Maybe you don't have to rewrite or edit much if you use search and replace (replace $this->Form->input by $this->TwitterBootstrap->input).

Resources