Skip to content

Password Strength Meter

Bootstrap 5 password input with show/hide toggle, four-step strength meter, live requirements checklist and confirmation match check.

Also known as: password strength indicator, password field with strength meter, password requirements checklist, confirm password input

Bootstrap 5 Inputs Responsive Dark #dark #form #input #password #validation

Password Strength Meter live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 password field with a show/hide button, a four-segment strength meter, a live requirements checklist and a confirmation field. It suits sign-up forms, password reset pages and account security settings, and ships as a dark card that sits on its own gradient backdrop.

How it works

The root is section.ps-wrap, which centers the .ps-card. The password uses a Bootstrap input-group: the .ps-input field and the .ps-toggle button. Clicking the toggle switches both password fields between type="password" and type="text", swaps the eye icon and updates aria-pressed and aria-label.

On every input event the script runs scorePassword(). It awards one point for each rule in the RULES object (length, mixed case, number, symbol) and then caps the result: under 8 characters the score cannot pass 1, under MIN_LENGTH it cannot pass 2. The score (0 to 4) is written to data-strength on the root, and CSS colors the first N .ps-meter__bar elements with --ps-level-color. The word from the LABELS array goes into .ps-strength__value. Each li[data-ps-rule] gets is-met, a filled check icon and hidden "met" text when its rule passes.

The .ps-confirm field compares itself with the password and writes "Passwords match" or "Passwords do not match" into .ps-match. On submit the form requires a score of at least 3 and a matching confirmation, then simulates saving with a short timeout and shows the result in .ps-status.

Customization

  • MIN_LENGTH in script.js: raise or lower the minimum length; also update the text of the length rule.
  • The RULES object in script.js: add a rule (for example no spaces) and a matching li with the same data-ps-rule key.
  • LABELS in script.js: rename the five strength levels shown after "Strength:".
  • --ps-weak, --ps-fair, --ps-good and --ps-strong in .ps-wrap: recolor the meter for each level.
  • --ps-accent in .ps-wrap: changes the submit button, the focus ring and the check icons.
  • --ps-bg, --ps-card and --ps-border in .ps-wrap: turn the dark card into a light one.
  • grid-template-columns in .ps-meter: use more segments if you also add more .ps-meter__bar spans and levels.
  • The window.setTimeout in the submit handler: replace it with a fetch() call to your backend.

Use cases

  • Sign-up forms: a four-segment meter shows how strong the new password is as users type
  • Password reset pages: a live checklist shows which requirements are still missing
  • Account security settings: a show and hide button helps users check what they typed
  • Registration flows: a confirmation field checks that both passwords match before submitting

Accessibility

Each field has a visible label. The password input is described by the strength text and the rules list through aria-describedby, and the strength line is an aria-live="polite" region, so screen readers hear the level only when it changes. The colored bars are aria-hidden, because the level is also written as text. The toggle is a real button with aria-controls, aria-pressed and a changing label. The confirmation sets aria-invalid when it does not match, and the save result is announced through role="status". Transitions are disabled under prefers-reduced-motion: reduce.

Usage notes

Requires Bootstrap 5 and Bootstrap Icons. The meter is a guide for users, not a security check: enforce your password policy on the server and consider checking passwords against known breach lists. For several instances on one page, give each input and its described-by targets unique ids.

Password Strength Meter at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Inputs
License
Free for personal and commercial use

Questions about this template

Can I use the Password Strength Meter code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Password Strength Meter – free Bootstrap 5 input template
Password Strength Meter · free Bootstrap 5 input template

More Inputs

Inputs with Icons and Add-ons – free Tailwind CSS input template

Inputs with Icons and Add-ons

Tailwind CSS input group examples with leading icons, text prefixes and suffixes, a currency select, password toggle, clear button and helper text.

Tag Input with Chips – free Bootstrap 6 input template

Tag Input with Chips

Dark Bootstrap 6 tag input that turns typed values into removable Chips, with suggestions, a tag limit, keyboard shortcuts and a live post preview.

Form Validation Styles – free Bootstrap 6 input template

Form Validation Styles

Bootstrap 6 signup form showing valid and invalid field states with specific feedback messages, a live status checklist and a simulated submit.

OTP Code Input – free Bootstrap 6 input template

OTP Code Input

Dark Bootstrap 6 OtpInput verification card with 6 digit slots, paste support, auto-advance, auto-verify on complete, error state and a resend countdown.

Password Input with Strength Meter – free Bootstrap 6 input template

Password Input with Strength Meter

Bootstrap 6 password field with show/hide toggle, the Strength meter, a live requirement checklist, confirm match, Caps Lock hint and a password generator.

Input Groups with Icons and Buttons – free Bootstrap 6 input template

Input Groups with Icons and Buttons

Bootstrap 6 input group examples in a settings card: icon and text prefixes, suffixes, a currency menu, stepper, copy button and validated coupon field.