diff --git a/js/component/form.js b/js/component/form.js index 4cad409e5..8bc9ecc78 100644 --- a/js/component/form.js +++ b/js/component/form.js @@ -1,4 +1,5 @@ var FormField = React.createClass({ + _fieldRequiredText: 'This field is required', _type: null, _element: null, @@ -8,7 +9,8 @@ var FormField = React.createClass({ }, getInitialState: function() { return { - warningState: 'hidden', + adviceState: 'hidden', + adviceText: null, } }, componentWillMount: function() { @@ -20,22 +22,26 @@ var FormField = React.createClass({ this._element = this.props.type; } }, - warnRequired: function() { + showAdvice: function(text) { this.setState({ - warningState: 'shown', + adviceState: 'shown', + adviceText: text, }); setTimeout(() => { this.setState({ - warningState: 'fading', + adviceState: 'fading', }); setTimeout(() => { this.setState({ - warningState: 'hidden', + adviceState: 'hidden', }); }, 450); }, 5000); }, + warnRequired: function() { + this.showAdvice(this._fieldRequiredText); + }, focus: function() { this.refs.field.focus(); }, @@ -61,7 +67,7 @@ var FormField = React.createClass({ {...otherProps}> {this.props.children} - This field is required + {this.state.adviceText} ); }