react-bforms
v0.4.1
Published
React boostrap form components.
Downloads
26
Readme
React Bootstrap Forms
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: [email protected]';
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 '';
};
};