How can use Pattern in my TextInput?
I have an input where I want to allow the entry of a maximum of 3 numbers separated from a . basically as if it were a float but instead of a comma a dot, I was searching and in the version of Filamentphp 2 it exists this:
->mask(fn (TextInput\Mask $mask) => $mask->pattern('+{7}(000)000-00-00'))
i try to use this:
But this is not working, how can do this?
Thank you.
3 Replies
i Fix using this code!
However, what I do not take into account is the maximum number of characters for this input, I tried 3 or 4 and it always accepts 3.33333333333 or 4.4444444, what would be ideal is for it to accept a maximum of 1.22, that is, a maximum length of 4 with the period included...
I believe there is a ->pattern() modifier that will add an actual pattern attribute to the input. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
MDN Web Docs
HTML attribute: pattern - HTML: HyperText Markup Language | MDN
The pattern attribute specifies a regular expression the form control's value should match. If a non-null value doesn't conform to the constraints set by the pattern value, the ValidityState object's read-only patternMismatch property will be true.