//判断前台是否AJAX请求
if(IS_AJAX){
$name = I("get.field"); //字段名称
$moduleid= I("get.moduleid"); //模型ID
$tablename = C('DB_PREFIX').strtolower($this->module[$moduleid]['name']); //模型表
$db = DB::getInstance(); //DB类库方法
$tables = $db->getTables(); //获取数据库的表
$Fields = $db->getFields($tablename);//获取字段信息方法
foreach($Fields as $key =>$r){
if($key==$name) $ishave=1; //存在变量$ishave=1;
}
if($ishave) { echo 'false';}else{echo 'true';}
exit;
}
Html:我用的是validate插件,只要是鼠标失去焦点触发 ajax 事件都可以!
*字段名