diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js index c8bb203..594492a 100644 --- a/src/components/dialog/edit-user.js +++ b/src/components/dialog/edit-user.js @@ -90,10 +90,9 @@ class EditUserDialog extends Component { this.handleChange(e)} /> - + E-mail this.handleChange(e)} /> - Role diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js index f666e31..fd01f99 100644 --- a/src/components/dialog/new-user.js +++ b/src/components/dialog/new-user.js @@ -20,7 +20,7 @@ ******************************************************************************/ import React, { Component, PropTypes } from 'react'; -import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; +import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap'; import Dialog from './dialog'; @@ -39,7 +39,7 @@ class NewUserDialog extends Component { username: '', mail: '', role: 'admin', - password: '1234' + password: '' }; } @@ -60,22 +60,26 @@ class NewUserDialog extends Component { username: '', mail: '', role: 'admin', - password: '1234' + password: '' }); } validateForm(target) { // check all controls - var username = true; + let username = this.state.username !== '' && this.state.username.length >= 3; + let password = this.state.password !== ''; - if (this.state.username === '') { - username = false; - } - - this.valid = username; + this.valid = username && password; // return state to control - if (target === 'username') return username ? "success" : "error"; + switch(target) { + case 'username': + return username ? "success" : "error"; + case 'password': + return password ? "success" : "error"; + default: + return "success"; + } } render() { @@ -86,12 +90,18 @@ class NewUserDialog extends Component { Username this.handleChange(e)} /> + Min 3 characters. - + E-mail this.handleChange(e)} /> + + Password + this.handleChange(e)} /> + + Role this.handleChange(e)}>