Home >Web Front-end >Layui Tutorial >How layui determines password inconsistency
Layui determines whether the passwords entered twice are consistent when registering: After submitting the password data in the form, Layui compares the passwords entered twice by calling js code and determines Is it consistent?
1. Confirm password
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>
js:
// 校验两次密码是否一致 form.verify({ confirmPass:function(value){ if($('input[name=password]').val() !== value) return '两次密码输入不一致!'; } });
Recommended: layuiframeworktutorial
The above is the detailed content of How layui determines password inconsistency. For more information, please follow other related articles on the PHP Chinese website!