think php5中有些正則不存在,例如手機號正則,此時我們可以自定義。代碼如下:
<?php
namespace app\master\validate;
use think\Validate;
class VentureloanValidate extends Validate
{
protected $rule = [
'fdrsj' => 'require|regex:1[3-8]{1}[0-9]{9}',
'fdryx' => 'require|email',
// gjyjzybhpz 國家一級中藥保護品種
'gjyjzybhpz' => 'require',
];
protected $message = [
'fdrsj.require' => '法定代表人手機不能為空',
'fdrsj.regex' => '手機號格式不正確',
'fdryx.require' => '法定代表人郵箱不能為空',
'fdryx.email' => '郵箱格式不正確',
'gjyjzybhpz.require' => '國家一級中藥保護品種不能為空',
];
}
手機號輸入錯誤,內(nèi)容如下

image.png
彈框如下

image.png