Layui表单账号注册校验密码是否一致
原创
©著作权归作者所有:来自51CTO博客作者CorwinPC的原创作品,请联系作者获取转载授权,否则将追究法律责任
HTML:
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">密码</label>
<div class="layui-input-inline">
<input type="password" name="password" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">确认密码</label>
<div class="layui-input-inline">
<input type="password" lay-verify="required|confirmPass" class="layui-input">
</div>
</div>
</div>
JavaScript:
// 校验两次密码是否一致
form.verify({
confirmPass:function(value){
if($('input[name=password]').val() !== value)
return '提示:两次输入密码不一致!';
}
});