F
Filament11mo ago
Antoine

Is it possible to add a mask to an email?

Is it possible to add a mask to an email? I need to force the user's hand to not be able to write values ​​not present in an email address like '&' or 'é'... I have a regex that works very well:
->regex('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ ');
->regex('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ ');
Is it possible to have a mask with RawJs in the same way? Like this :
->mask(RawJs::make('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/'));
->mask(RawJs::make('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/'));
In v2, we had the opportunity :
->mask(fn (Mask $mask) => $mask->pattern('00/00'))
->mask(fn (Mask $mask) => $mask->pattern('00/00'))
Thanks
3 Replies
Antoine
AntoineOP11mo ago
Of course I can, and I already use it as such, but I'm not looking for a workaround when we have the mask() method and we don't use it to its full capacity. Hence my question, does the mask() method have this capability?
Tim van Heugten
Tim van Heugten11mo ago
As its an implementation of Alpine.js’ Mask plugin (https://alpinejs.dev/plugins/mask) I guess you should ask around in their community. You can always implement something yourself, just be aware that the onKeydown solutions don’t cover copy/paste scenarios.
Mask — Alpine.js
Automatically format text fields as users type
Want results from more Discord servers?
Add your server