F
FilamentWEBMAS

How to enter only letters and numbers in TextInput?

How to enter only letters and numbers? Something like the regular expression [a-zA-Z0-9_] TextInput::make('telegram') ->label(__('page.profile.fields.telegram')) ->prefix('@') ->minLength(5) ->maxLength(32),
W
WEBMAS40d ago
Help please 😔
A
awcodes40d ago
->extraInputAttributes([‘pattern’ => ‘regrex’]) 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.
A
awcodes40d ago
Or possibly use a mask()
W
WEBMAS40d ago
Thank you. I tried to do it through a mask, but I never found instructions on how to make only numbers and letters. Of course, I would like to do it through a mask. But how?
A
awcodes40d ago
Probably better to do it with the pattern. Just let the browser handle it.
W
WEBMAS40d ago
If you do ->extraInputAttributes([‘pattern’ => ‘regrex’]), then I think the backend validation will not work. If you remove this attribute in the browser through code viewing tools, the server will accept incorrect data.
S
sandofgods40d ago
you can't do that with ->mask, it's using alpine.js mask (https://alpinejs.dev/plugins/mask#x-mask) and it's handling Any, Only Alpha, Only Numeric. But, you cant use this one https://filamentphp.com/docs/3.x/forms/validation#alpha-numeric
Mask — Alpine.js
Automatically format text fields as users type
W
WEBMAS40d ago
This Field::make('name')->alphaDash() looks like what I need. Thank you. I'll try it tomorrow.
Want results from more Discord servers?
Add your server
More Posts
Default Redirect UrlI see that it is possible to change the default redirect url for edit/create for a given resource byHow to save the value of hidden toggle?I have two toggles. If the first one is on, it will show the second toggle. If the frist one is ofShow date to frontend, but save anotherWhat would be the best way to show data to the frontend, but save something different to the db? I aOverride `getColors()` from enum for toggle buttonsHi all. I'm using an enum in 2 places: a badge column and a toggle button. The badges need to usimage not loading but accessible via URLHi am uploading an image and i also run php artisan storage:link and still image is not loading thishiddenOn returns an error when creating a resourceSo, on my app I had to add creation of whitelists. Before that you could only view the resource, yousave repeater values as json to DBhello i have a repeater which post the value as an array and when i try to insert data i got > `ArraHow close filament modal in custom page```php <x-filament::modal id='custom-modal-handle'> <x-slot name='header'>Tambah Nominal</x-slotBackgrounds plugin by SWISI try to use this plugin by SWIS https://filamentphp.com/plugins/swisnl-backgrounds#remember which iGroup By in tablePlease is it possible for the id to be starting from 1 in each groupingproblem with customized searchable text columnhttps://filamentphp.com/docs/2.x/tables/columns/getting-started#searching Does anyone know the corrSave relationship first before creating modelSo I need to save the relationship first then create a model and sync itCalculate Totals in the footer for a table componentHow can calculate the total balance of the customers and show it in the footer .Note this table compFilter using columnsHello, I'm having difficulty creating a filter in a query that I inserted in the columns. How can I Hiring a senior mobile app developer from India or PakistanI have some mobile projects. I want someone have over 3 years experience. And especially I hope reacGet current row record in custom action```php Tables\Actions\Action::make('make_additional_payment') ->label('Наплати дSelect multiple preloaded options are reordered after selecting the inputI have a select multiple that is formFilled with options already attached on a BelongsToMany relatioError on trying to edit or create a new role at SHIELD pluginIm getting ```count(): Argument #1 ($value) must be of type Countable|array, null given``` this errotesting repeater / fillForm / fill default itemHi - I'm just getting started writing tests for my app with Pest. My first and most high-traffic resUse fa-icon in table builderI'm working in a project who already have a database in production. The database have a table with a