Forms
Password strength
A meter, a helpful tip and an optional checklist under a new-password field — plus a show / hide button, a "passwords match" check and a Caps Lock warning. All from attributes on the input.
<input class="form-control" id="password" type="password" autocomplete="new-password" required
data-moey-strength data-moey-rules="12,upper,number,symbol"
data-moey-strength-min="3" data-moey-strength-avoid="#email" data-moey-toggle>
<input class="form-control" type="password" autocomplete="new-password" required
data-moey-match="#password" data-moey-toggle>
- The meter goes from Very weak to Strong. It rewards length and variety, and knows the usual tricks: common passwords ("P@ssw0rd" is still "password"), repeats like "aaa", sequences like "1234" or "qwerty", and your own name or email (
data-moey-strength-avoid). - The tip says what would help most; with
data-moey-rulesthe checklist ticks off as you type. - The form won't send a password that misses a rule or is below
data-moey-strength-min, or a repeat that doesn't match — with a clear message. - Caps Lock: a warning appears while it's on. Try it.
Just the meter
Without rules it's only the bar and the tip — good for "change password" pages. data-moey-toggle works on any password field, also with floating labels.
<input class="form-control" type="password" data-moey-strength>
<div class="form-floating">
<input class="form-control" id="new" type="password" data-moey-strength data-moey-toggle>
<label for="new">New password</label>
</div>
From code
Moey.strength('Tr0ub4dor&3'); // { score: 3, label: 'Good', hint: 'A few more characters make it strong' }
input.addEventListener('moey:strength', (e) => {
e.detail.score; // 0 (very weak) … 4 (strong)
e.detail.rules; // { length: true, upper: false, number: true, symbol: false }
});
It's a guide for people choosing a password — always check passwords on your server too.
| Attribute | What it does |
|---|---|
data-moey-strength | The meter and tip under the field |
data-moey-rules="12,upper,lower,number,symbol" | A checklist (a number = minimum length); the form needs them all |
data-moey-strength-min="3" | The weakest score the form accepts (0–4) |
data-moey-strength-avoid="#email, #name" | Using what's typed in those fields counts as weak |
data-moey-toggle | An eye button to show / hide the password |
data-moey-match="#password" | Must be the same as that field (data-moey-match-message for your own text) |