$name = $_POST['name'];//$this->error($name); 这里可以输出“小明”if(!preg_match('/^[u4E00-u9FA5]{2,4}$/',$name)) { $this->error('真实姓名应由2-4个汉字组成!');}
但是老是提示“真实姓名应由2-4个汉字组成!”,没法通过
if(!preg_match('/^1[0-9]{10}$/',$_POST['mobile'])) {
$this->error('请输入正确的手机号码!!');
}
输入正确的手机号码可以通过,想JS+PHP两重验证。JS部分已经OK了
回复讨论(解决方案)
你的 /^[u4E00-u9FA5]{2,4}$/ 是 js 的正则表达式规则串
php 要写作 '/^[\x{4e00}-\x{9fa5}]{2,4}$/u'
哦,还有这分别,谢谢了!搞定
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn