Import the class and register it
The class-only import does not register an element. Both icon states inherit the rule’s text color. These patterns illustrate requirement matching, not a comprehensive password check or a measure of strength.
import { FormValidationListElement } from
'https://esm.sh/@aarongustafson/form-validation-list@2.3.3/form-validation-list.js?bundle&target=es2022';
if (!customElements.get('form-validation-list')) {
customElements.define('form-validation-list', FormValidationListElement);
}
<label for="password">Password</label>
<input type="password" id="password" name="password">
<form-validation-list for="password">
<ul>
<li data-pattern=".{8,}">At least 8 characters</li>
<li data-pattern="[A-Z]+">One uppercase letter</li>
<li data-pattern="[\d]+">One number</li>
</ul>
</form-validation-list>
- At least 8 characters
- One uppercase letter
- One number
If the module cannot load, the field and requirements remain visible, but the extra rules are not enforced. Always validate submitted values on the server.