So, I have the following rules in my model:
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',
);
But, for some reason, when the regex is applied in the pattern
attribute tag in html... it breaks!
Result:
<input required="true" pattern="^[0-9]{" class="form-control" ....>
_________
\
=> This right here should be
^[0-9]{1,3}(\.?)[0-9]{1,2}$
Try using like this.
array(
'field' => 'regex:[a-z]'
);
Hope this would helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With