动态验证的操作方法function yz() { if(empty($_POST)) { $this->display(); } else { $db=D("Info"); $shu=array( array("Code","require","代号不能为空",0,"regex",3), ); if(!$db->validate($shu)->create()) { echo $db->getError(); } else { echo"验证通过"; } } }
在框架里用ajax来实现输入代号显示姓名 打到模板是用上面的function ming() { $code=$_POST["code"]; $db=D("Info"); $data=$db->find($code); $name=$data["name"]; $this->ajaxReturn($name,"eval"); }
表单
代号:
js代码