我正在使用以下代码,我需要匹配表单内的密码。它不适用于此处和其他网站上提供的大多数帮助。我可能错过了一些我无法追踪的东西。请帮我解决这个问题。
HTML
<form id="user_form" class='has-validation-callback'>
<input type="password" name="pass_confirmation" class="form-control" data-validation="length" data-validation-length="min6">
<input type="password" name="pass" id="pass" class="form-control" data-validation-confirm="confirmation" data-validation-help="Please give us some more information">
</form>
JavaScript
$.validate({
modules : 'security',
form : '#user_form',
onError : function() {
alert('Sorry! Please complete the form fields.');
}
});
链接到库
http://cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.19/jquery.form-validator.js
最佳答案
This validator can be used to validate that the values of two inputs are the same. The first input should have a name suffixed with _confirmation and the second should have the same name but without the suffix.
<input type="password" name="pass_confirmation" class="form-control" data-validation="length" data-validation-length="min6">
<input type="password" name="pass" id="pass" class="form-control" data-validation="confirmation" data-validation-help="Please give us some more information">
对于第二个输入,将属性 data-validation-confirm="confirmation"
更改为 data-validation="confirmation"
它将起作用。
工作中fiddle
关于javascript - 使用 jquery 表单验证进行密码验证 jquery.form-validator.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37380697/