html 5 验证密码和确认密码

man*_*ish 2 html html5-canvas

如何使用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>
Run Code Online (Sandbox Code Playgroud)

小智 6

你可以试试这个

<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>
Run Code Online (Sandbox Code Playgroud)