密码与确认密码:跨字段校验 | 星雨笔录
理解确认密码等跨字段规则需要脚本补充。
核心: 浏览器能验证单个字段,但两次密码是否相等需要 JavaScript 做跨字段校验。
最小示例:
<input id="pwd" type="password" minlength="8">
<input id="confirm" type="password" minlength="8">
<!-- JS 检查:pwd.value === confirm.value -->
学完能做: 理解确认密码等跨字段规则需要脚本补充。