Currency/Money Format Help

I was wondering if anyone would happen to know how to create a mask, pattern, or whatever would work to get a result like the following. For context, the user can't delete or clear the form field, but can only type in numbers that are automatically formatted.
3 Replies
Dan Harrin
Dan Harrin15mo ago
i think this is more than just a mask masks just format, whereas this is able to shift digits
LeandroFerreira
LeandroFerreira15mo ago
You can use extraInputAttributes/extraAlpineAttributes:
->extraInputAttributes(['@input' => '
input = $el.value.replace(/\D/g, \'\');
input = (input / 100).toFixed(2) + \'\';
//...
$el.value = input;
'])
->extraInputAttributes(['@input' => '
input = $el.value.replace(/\D/g, \'\');
input = (input / 100).toFixed(2) + \'\';
//...
$el.value = input;
'])
ChatGPT can help you with the js function
Andrew Wallo
Andrew Wallo15mo ago
Okay thanks. I will try something like the above or I guess this probably would have to be done by making a custom component.