question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make validation to confirm password ()

See original GitHub issue

How to make validation to mutch checking 2 fields ?

Method below work, but register: required and minLength works only onBlur…

<input type="text" name="newPassword" ref={register({ required: true, minLength: 8})}
onChange={e => {
    const value = e.target.value
    if (value !== password) return clearError("confirmPassword")
    setError("confirmPassword", "notMatch", "passwords not mutch")
}}

required autoFocus/>

Without mutch checking register: required and minLength work good.

<input type="text" name="newPassword" ref={register({ required: true, minLength: 8})} placeholder="Новый пароль" required/>

In ( required: validate: (value) => value === password ) program not watch const password …

<input type="text" name="newPassword" ref={register({ validate: (value) => value === password })} placeholder="Новый пароль" required/>

Who maked same validation to mutch checking fields ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:35 (17 by maintainers)

github_iconTop GitHub Comments

59reactions
bluebill1049commented, Aug 18, 2019
<input type="text" name="newPassword" ref={register({
  validate: (value) => value === watch('password')
})} placeholder="Новый пароль" required/>

it’s closure, you need to move watch inside the function.

45reactions
dmt0commented, Jan 23, 2020

In case someone else bumps into this. Using example above the error never showed up for me, I needed to add the error message output to the validate function.

<input type="text" name="newPassword" ref={register({
  validate: (value) => value === watch('password') || "Passwords don't match."
})} placeholder="Новый пароль" required/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Confirm password validation in JavaScript - javatpoint
Confirm password validation in JavaScript · A password should be alphanumeric. · First letter of the password should be capital. · Password must...
Read more >
How to validate confirm password using JavaScript
First of all, we will type the password in both password input and confirm password input then we will compare both the input...
Read more >
Laravel Password & Password_Confirmation Validation
I have a paasword and a confirm password field i have validated it using laravel but even the password is same for both...
Read more >
How To Create a Password Validation Form - W3Schools
Learn how to create a password validation form with CSS and JavaScript. Password Validation. Try it Yourself ». Create A Password Validation Form....
Read more >
Password and Confirm Password validation using JavaScript ...
Inside the Validate JavaScript function, the values of the Password and the Confirm Password TextBoxes are fetched and are compared. If the values...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found