Password Checklist

Demo playground

Signup form integration

Gate form submission on password validity. Use the hook to access isValid.

  • At least 8 characters — fails
  • At least one uppercase letter — fails
  • At least one lowercase letter — fails
  • At least one number — fails
  • At least one special character — fails
  • Passwords match — fails

Snippet

Copy the example to your clipboard.

const { isValid } = usePasswordValidation({
  value: password,
  valueAgain: confirmPassword,
  rules: ["minLength", "capital", "lowercase", "number", "specialChar", "match"],
});

<form onSubmit={handleSubmit}>
  <button disabled={!isValid}>Sign up</button>
</form>