© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3mo ago•
7 replies
beety

Live validation of a required field

Hi. I want my form to validate a field after it's blurred. One of the validation rule is ->required().
This is the code:
TextInput::make('name')
    ->label('Name')
    ->required()
    ->unique() 
    ->maxLength(255)
    ->live(onBlur: true)
    ->afterStateUpdated(function ($livewire, $component) {
        $livewire->validateOnly($component->getStatePath());
    })
TextInput::make('name')
    ->label('Name')
    ->required()
    ->unique() 
    ->maxLength(255)
    ->live(onBlur: true)
    ->afterStateUpdated(function ($livewire, $component) {
        $livewire->validateOnly($component->getStatePath());
    })

This works well for the other rules (such as unique), but not for the required rule.
It kind of makes sense, as the field is initially empty and is not updated before it's blurred.
It does, of course, work if the user changes the input field but leaves it empty.
But is there a way or a workaround to make it work when the user did not change
the field after it's blurred?

Thank you in advance.
Solution
a workaround

->extraInputAttributes(['x-ref' => 'name'])
->extraAlpineAttributes(['x-on:blur' => '$refs.name.dispatchEvent(new Event(\'input\'))'])
->extraInputAttributes(['x-ref' => 'name'])
->extraAlpineAttributes(['x-on:blur' => '$refs.name.dispatchEvent(new Event(\'input\'))'])
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Select Field Required Wrong Validation
FilamentFFilament / ❓┊help
2y ago
Required field validation with translatable plugin
FilamentFFilament / ❓┊help
3y ago
Validation of field inside a repeater.
FilamentFFilament / ❓┊help
3y ago
Field required validation error, even when field is filled.
FilamentFFilament / ❓┊help
12mo ago