Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import Form from './common/form';
- import Joi from 'joi-browser';
- class RegisterForm extends Form {
- state = {
- data: { username: '', password: '', name: '' },
- errors: {}
- };
- schema = {
- username: Joi.string()
- .email()
- .required()
- .label('Username'),
- password: Joi.string()
- .required()
- .min(5)
- .label('Password'),
- name: Joi.string()
- .required()
- .label('Name')
- };
- doSubmit = () => {
- // Call the server
- console.log('submitted');
- };
- render() {
- return (
- <div>
- <h1>Register</h1>
- <form onSubmit={this.handleSubmit}>
- {this.renderInput('username', 'Username')}
- {this.renderInput('password', 'Password', 'password')}
- {this.renderInput('name', 'Name')}
- {this.renderButton('Login')}
- </form>
- </div>
- );
- }
- }
- export default RegisterForm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement