Description
In documentation says:
confirmed
The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.
Code:
this.form.useRules({ first_name: "required", last_name: "required", email: "required|email", password: "required|passwordchk|confirmed" });
Form:
<input type="password" className={this.state.errors.password ? "form-control is-invalid" : "form-control"} name="password" id="password" placeholder="Create password" onBlur={this.form.handleBlurEvent} onChange={this.form.handleChangeEvent} value={this.state.fields.password} noValidate /> <input type="password" className={this.state.errors.password_confirmation ? "form-control is-invalid" : "form-control"} name="password_confirmation" id="password_confirmation" placeholder="Confirm password" onBlur={this.form.handleBlurEvent} onChange={this.form.handleChangeEvent} value={this.state.fields.password_confirmation} noValidate />
Output:
errors
{password: "The password confirmation does not matc…}
password
"The password confirmation does not match."
fields
{email: "", first_name: "", last_name: "", password…}
email
""
first_name
""
last_name
""
password
"Pass@123."
password_confirmation
"Pass@123."
isValidatorUpdate
true