【问题标题】:html 5 validation of password and confirm passwordhtml 5 验证密码并确认密码
【发布时间】:2015-10-20 08:05:54
【问题描述】:

如何使用html 5在注册表中验证密码并确认密码?我知道如何使用 java 脚本和 jquery。但我是 html5 的新手,所以想使用它。

        <input type="password" placeholder="Password" name="password" id='password1' required>
        <input type="password" placeholder="Confirm Password" name="confirm_password" id="password2" required>

【问题讨论】:

  • 我真的不认为只有 HTML5 可以做到这一点。 HTML5 确实启用了一些验证,甚至是模式匹配,但我认为它不能比较两个字段。我很确定您需要一些 javascript 来比较这两个值。

标签: html html5-canvas


【解决方案1】:

你可以试试这个

<input id="password" name="password" type="password" pattern="^\S{6,}$" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Must have at least 6 characters' : ''); if(this.checkValidity()) form.password_two.pattern = this.value;" placeholder="Password" required>

<input id="password_two" name="password_two" type="password" pattern="^\S{6,}$" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Please enter the same Password as above' : '');" placeholder="Verify Password" required>

【讨论】:

    猜你喜欢
    • 2015-04-03
    • 2023-02-23
    • 1970-01-01
    • 2015-05-18
    • 1970-01-01
    • 2013-09-18
    • 2017-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多