所以,我的模型中有以下规则:
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,'handling' => array('regex:/^[0-9]{1,'insurance' => 'required|numeric',);
但是,出于某种原因,当正则表达式应用于html中的模式属性标记时…它会中断!
结果:
<input required="true" pattern="^[0-9]{" class="form-control" ....> _________ \ => This right here should be ^[0-9]{1,2}$
尝试使用这样的.
原文链接:https://www.f2er.com/laravel/137183.htmlarray( 'field' => 'regex:[a-z]' );
希望这会有所帮助.