Input masking

In version V2 of Filament, I had this mask:
->mask(fn (TextInput\Mask $mask) => $mask->pattern('{{ /^[0-9kK]*$/ }}'))
->mask(fn (TextInput\Mask $mask) => $mask->pattern('{{ /^[0-9kK]*$/ }}'))
But how can I achieve the same thing in the new version using the regular expression? I'm not sure why this expression doesn't work:
->mask(RawJs::make(<<<'JS'
return '/^[0-9kK]*$/'
JS))
->mask(RawJs::make(<<<'JS'
return '/^[0-9kK]*$/'
JS))
Could you please help me with this?
4 Replies
Shaung Bhone
Shaung Bhone5mo ago
TextInput::make('cardNumber')
->mask(RawJs::make(<<<'JS'
$input.startsWith('34') || $input.startsWith('37') ? '9999 999999 99999' : '9999 9999 9999 9999'
JS))
TextInput::make('cardNumber')
->mask(RawJs::make(<<<'JS'
$input.startsWith('34') || $input.startsWith('37') ? '9999 999999 99999' : '9999 9999 9999 9999'
JS))
gustavo.dev
gustavo.dev5mo ago
But how can I add this regular expression /^[0-9kK]*$/ because it doesn't seem to work?
krekas
krekas5mo ago
firefox browser? with firefox it seems doesn't work
Antoine
Antoine5mo ago
How can I use a regex like this '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/' with masks? It's ok for numbers like $money but not for a regex?
Want results from more Discord servers?
Add your server
More Posts