/react-form

Primary LanguageJavaScript

react-router

React Form from Qrator

Easy way to validate forms in React

Docs

Read API docs

Get started

Instalation

Install react-form directly from gitlab repo

npm i -S @qrator/react-form

Create you first form

You may use webpack or some module bundler for writing code in ES6 syntax

import * as React from 'react';
import Form, { InputControl } from '@qrator/react-form';

let notEmpty = val => val.trim();

class MyForm extends React.Component {
  handleSubmit(data) {
    // save it on a server
  }
  render() {
    return (
      <Form onSubmit={::this.handleSubmit}>
        <InputControl name='login' validators={[{
          name: 'empty', msg: 'Enter login', f: notEmpty
        }]}/>
        <InputControl
            name='password'
            type='password'
            validators={[name: 'empty', msg: 'Required field', f: notEmpty]}/>
        <button type='submit'>Submit</button>
      </Form>
    );
  }
}

export default MyForm;

You may start demo by command

npm run example -- --env.name signup

After you should open http://localhost:8080 to see demo in your browser