我formValidator
从FormValidator.net使用,我有一种情况,我需要验证密码并比较密码字段,根据插件,我们可以这样做。
<p>
Password (at least 8 characters)
<input name="pass_confirmation" data-validation="length" data-validation-length="min8"/>
Confirm password
<input name="pass" data-validation="confirmation"/>
</p>
由于我使用的是他们最新版本的插件,我还尝试了他们建议的最新版本 >2.2.1
如下:
<p>
Password (at least 8 characters)
<input name="pass_confirmation" data-validation="length" data-validation-length="min8"/>
Confirm password
<input name="pass" data-validation="confirmation" data-validation-confirm="pass_confirmation"/>
</p>
但它仍然根本没有比较密码。虽然我可以说最小值比较password
是正确的。有人研究过这个插件吗?有没有其他方法可以做到这一点?
$.validate({
form: "#frmSample",
validateOnBlur: true, // enable validation when input looses focus
scrollToTopOnError: true, // Set this property to true if you have a long form
borderColorOnError: "rgb(167, 3, 0)",
borderColorOnSuccess: "#a94442",
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.2.43/jquery.form-validator.min.js"></script>
<form id="frmSample">
<p>
Password (at least 8 characters)
<input name="pass_confirmation" data-validation="length" data-validation-length="min8">
<br/>
Confirm password
<input name="pass" data-validation="confirmation">
</p>
</form>