0.4.1 • Published 6 years ago

react-bforms v0.4.1

Weekly downloads
5
License
MIT
Repository
-
Last release
6 years ago

React Bootstrap Forms

Demo

Quick example

import BForms from 'react-bforms';
var {Form, Input} = BForms;


export class LoginForm extends React.Component {

    render() {
        return (
            <Form ref='form' onSubmit={this._onSubmit.bind(this)}>
                <Input name='username'
                       label='Email'
                       type='email'
                       validators={[username()]}/>

                <Input name='password'
                       label='Password'
                       type='password'
                       validators={[password()]}/>

                <div>
                    <button className='btn btn-primary'>Login</button>
                </div>
            </Form>
        );
    }

    _onSubmit() {
        var values = this.refs.form.getValues();
        console.log(values);
    }
};


var username = function(message) {
    message = message || 'Example: username@example.com';

    return function(value) {
        if (value.indexOf('@') === -1) {
            return message;
        }

        return '';
    };
};


var password = function(message) {
    message = message || 'Please enter password';

    return function(value) {
        if (!value) {
            return message;
        }

        return '';
    };
};
0.4.1

6 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago