Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Fzoltan87's avatar

Laravel Numeric Mask Input Blade Component with Livewire and Imask

Hello. I created a Laravel Blade component that generates an input field where only numbers can be entered, and it also renders a formatted display below the input field. My problem is that when I use the live parameter and type slowly into the input field, the entered numbers disappear, as if they were constantly being overwritten.

Component contents: resources\views\components\numeric-mask-input.blade.php

This is how I call it in the form:

        @if($type_id === 1)
            <div class="md:col-span-3">
                <x-numeric-mask-input name="price_sale" label="Price" wire:model.defer="price_sale" max="99999999999"
                    suffix="EUR" required />

                @if($price_sale)
                    <p class="mt-2 text-sm text-gray-600 transition-opacity duration-300 ease-in-out">
                        Preview Price Format:
                        <strong>{{ \App\Services\Helper::formatPriceToList($price_sale) }}</strong>
                    </p>
                @endif
            </div>
        @endif


0 likes
1 reply
Jsanwo64's avatar

Replace

value: @entangle($attributes->wire('model')).live,

with

value: @entangle($attributes->wire('model')).defer,

If you really need live updates

If you must have Livewire receive updates on each keystroke:

Don’t use entanglement at all. Instead, fire a Livewire update manually inside mask.on('accept'):

mask.on('accept', () => {
    raw = mask.value;
    value = mask.unmaskedValue;
    $wire.set('{{ $attributes->wire('model')->value() }}', mask.unmaskedValue, true);
});

Please or to participate in this conversation.