html5验证新密码和旧密码

时间:2014-06-10 09:10:47

标签: javascript php html5 validation passwords

我使用html5进行密码验证,我在此处找到http://www.the-art-of-web.com/javascript/validate-password/ 我有一个用于编辑用户帐户的表单,在那里我给textfield包含新密码和旧密码。 如果未填写新密码字段,则将存储数据,如果必须填写旧密码字段中填写的新密码字段,那么我该如何提供验证?如果字段中的旧密码给定了所需的属性,那么如果用户不想更改密码该怎么办。

这是表格..

<label>New Password</label>
    <div class="form-group">
        <input class="form-control" type="password" name="password" id="password" placeholder="Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}"
        onchange=" this.setCustomValidity(this.validity.patternMismatch ? 'Password must contain at least 6 characters, including UPPER/lowercase and numbers' : '');"
        >
    </div>

    <label>Old Password</label>
    <div class="form-group">
        <input type="hidden" name="confirm_hide" id="confirm_hide" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}"
        onchange=" this.setCustomValidity(this.validity.patternMismatch ? 'Password must contain at least 6 characters, including UPPER/lowercase and numbers' : ''); if(this.checkValidity()) form.confirm.pattern = this.value; "
        >
        <input class="form-control" type="password" name="confirm" id="confirm" placeholder="Password" " pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}"
        onchange=" this.setCustomValidity(this.validity.patternMismatch ? 'Please enter valid current password' : ''); "
        >
    </div>

0 个答案:

没有答案