Skip to content

Commit

Permalink
removed issues related to error message on login page
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Feb 22, 2024
1 parent 3fa1f6b commit da80c79
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,11 @@ class TextboxElement extends Component {
*/
constructor(props) {
super(props);
// ########### CBIGR START ###########
this.state = {
isTouched: false,
};
// ########### CBIGR END ###########
this.handleChange = this.handleChange.bind(this);
this.handleBlur = this.handleBlur.bind(this);
}
Expand All @@ -1147,6 +1152,9 @@ class TextboxElement extends Component {
* @param {object} e - Event
*/
handleBlur(e) {
// ########### CBIGR START ###########
this.setState({isTouched: true});
// ########### CBIGR END ###########
this.props.onUserBlur(this.props.name, e.target.value);
}

Expand All @@ -1171,7 +1179,10 @@ class TextboxElement extends Component {

// Add error message
// ########### CBIGR START ###########
if (this.props.errorMessage || (required && this.props.value === '')) {
if (this.state.isTouched && (
this.props.errorMessage ||
(required && this.props.value === '')
)) {
errorMessage = (
<span>{this.props.errorMessage || 'The field is required!'}</span>
);
Expand Down

0 comments on commit da80c79

Please sign in to comment.