TP5 驗證兩次輸入密碼是否一致
阿新 • • 發佈:2019-01-22
增加了欄位自動匹配驗證規則,如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