$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":"验证码不正确"} 