zahra zamani
zahra zamani

Reputation: 1375

How should I check if the password is weak or good After applying PasswordStrengthBar?

I'm using PasswordStrengthBar import PasswordStrengthBar from 'react-password-strength-bar'; https://www.npmjs.com/package/react-password-strength-bar

I want to display a message when the confirmation button is clicked and the password is weak .. How should I check if the password is weak or good?

<input type="password" className="form-control" value={this.state.newPassword} onChange={this.passwordOnChange} id="pwd" />
<PasswordStrengthBar   password={this.state.newPassword}   />

Upvotes: 0

Views: 436

Answers (1)

Yaya
Yaya

Reputation: 4848

According to github source of this package

https://github.com/lannex/react-password-strength-bar/blob/master/examples/src/Home.js

you can call a function whenever score changes with onChangeScore attribute

 <PasswordStrengthBar
        password={this.state.newPassword}
        onChangeScore={score => {
          console.log(score);
        }}
      />

Upvotes: 3

Related Questions