所以,我的模型中有以下规则:
public static $rules = array(
'name' => 'required|alpha_dash|unique:subsidiaries',
'internal_number' => 'required|alpha_dash|unique:subsidiaries',
'expedition_rate' => array('required', 'regex:/^[0-9]{1,3}(\.?)[0-9]{1,2}$/'),
'hundred_kg_rate' => array('regex:/^[0-9]{1,5}(\.?)[0-9]{1,2}$/'),
'handling' => array('regex:/^[0-9]{1,3}(\.?)[0-9]{1,2}$/'),
'insurance' => 'required|numeric',
);
但是,由于某种原因,当正则表达式应用于pattern
html 的属性标记时......它会中断!
结果:
<input required="true" pattern="^[0-9]{" class="form-control" ....>
_________
\
=> This right here should be
^[0-9]{1,3}(\.?)[0-9]{1,2}$