2

我正在尝试集成材料组件网络。

带有验证消息的文本框的第一个用例不起作用。文本框有效,但验证消息无效。如何使验证消息起作用?

 <script>
    mdc.textField.MDCTextField.attachTo(document.querySelector('#passbox'));
    
    mdc.textField.MDCTextField.attachTo(document.querySelector('.mdc-text-field-helper-text--validation-msg'));
    </script>

<label id="passbox" class="mdc-text-field mdc-text-field--filled">
        <span class="mdc-text-field__ripple"></span>
        <input class="mdc-text-field__input" type="password" aria-labelledby="my-label-id" required minlength="8">
        <span class="mdc-floating-label" id="my-label-id">Password</span>
        <span class="mdc-line-ripple"></span>

        <span class="mdc-text-field-helper-line">
            <span id="email-helper-text" class="mdc-text-field-helper-text--validation-msg" aria-hidden="true">
                Minimum password lenght is 8 characters.
            </span>
        </span>
    </label>
4

0 回答 0