TP5 验证两次输入密码是否一致
转载
增加了字段自动匹配验证规则,如password和password_confirm是自动相互验证的,只需要使用
'password'=>'require|confirm'
例子:html
<input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off"
class="layui-input">
<input type="password" name="password_confirm" required lay-verify="required" placeholder="请输入密码"
autocomplete="off" class="layui-input">
TP5代码:'password'=>'require|confirm',
$validate = new Validate([
'type' => 'require',
'username' => 'require|max:8',
'tel' => 'require|max:8',
'nickname'=>'chs',
'tel'=>'number|length:11',
'qq'=>'number',
'password'=>'require|confirm',
'email' => 'email'
]);
官方文档:https://www.kancloud.cn/manual/thinkphp5/129356