Numeric but can be blank
I have a form that includes the following
However, when I try to submit the form, if this field is left blank, I get the following validation error
The company Number field must be a number.Is there a way to require the field to be numeric or blank? Also as a slight aside, how do I capitalise the 'c' in the validation error?
2 Replies
Try doing nullable() before numeric()
Sometime the order matters.
If that doesn’t work you can always do it manually with ->rules([‘nullable’, ‘digits’])
Things like nullable and sometimes have to be first in the validations in laravel since they will bail the validation.
Thanks @awcodes. Unfortunately, even moving nullable() first I get the same error.
Weirdly though, when I tried the second suggestiong using 'digits' it showed some weird characters in the field even though it should be blank.