Validate 验证配合js对应操作

浏览:969 发布日期:2017/05/02 分类:用法示例 关键字: Validate 验证
Validate 验证配合js对应操作
$msg2 = ['code.require'=>'验证码不能为空','code.captcha'=>'验证码不正确'];
$validate = new Validate(['code'=>'require|captcha'],$msg2);
if(!$validate->check(input('post.'))){
    $json['t']=$validate->getError();
    $json['p']=yz_back($json['t'],$msg2);
    $this->ajax_return($json);
}

//返回input name
function yz_back($text,$arr){
  $ear=explode('.',array_search($text,$arr));
  return $ear[0];
}


//返回 {"p":"code","t":"验证码不正确"}
评论( 相关
后面还有条评论,点击查看>>