Answer the question
In order to leave comments, you need to log in
How to clear the form correctly so that the message about saving the password does not pop up?
Hello. I'm making a simple form to create a user, and ran into a problem. I write in React. Here is the code:
<form
id="user-form"
autoComplete="off"
noValidate>
<div className="form-group">
<div>
<label>First Name:</label>
</div>
<TextField
name="firstName"
hintText="First name"
value={this.state.firstName}
onChange={this.handleChange} />
</div>
<div className="form-group">
<div>
<label>Last Name:</label>
</div>
<TextField
name="lastName"
hintText="Last name"
value={this.state.lastName}
onChange={this.handleChange} />
</div>
<div className="form-group">
<div>
<label>Password:</label>
</div>
<TextField
type="password"
name="password"
hintText="Password"
value={this.state.password}
onChange={this.handleChange} />
</div>
<div className="form-group">
<div>
<label>Confirm Password:</label>
</div>
<TextField
type="password"
name="confirmPassword"
hintText="Confirm password"
value={this.state.confirmPassword}
onChange={this.handleChange} />
</div>
<div className="form-footer">
<button
className="btn btn-outline-primary"
type="submit"
onSubmit={this.handleSubmit}>
Save
</button>
<span className="button-devider"></span>
<button
className="btn btn-outline-danger"
type="reset"
onClick={this.handleReset}>
Cancel
</button>
</div>
</form>
handleReset(event) {
this.setState(this.baseState);
document.getElementById('affiliate-form').reset();
// setTimeout(() => this.props.history.push('/users'), 0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question