---
title: "Discussion on \"Replacing oninput with x-mask\" | Hashnode"
description: "Discussion on \"Replacing oninput with x-mask\". Add comma separator to numbers in text fields as an when you type"
url: "https://hashnode.com/posts/replacing-oninput-with-x-mask/638732935cd93cbec20ad862"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Replacing oninput with x-mask](https://alpinejs.in/replacing-oninput-with-x-mask?utm_source=hashnode&utm_medium=feed)

Add comma separator to numbers in text fields as an when you type

Nov 30, 2022 · 1 min read · alpinejs.in  
Read the article

-   [#commas](https://hashnode.com/tag/commas)
-   [#numbers](https://hashnode.com/tag/numbers)
-   [#html](https://hashnode.com/tag/html)
-   [#plugin](https://hashnode.com/tag/plugin)
-   [#alpinejs](https://hashnode.com/tag/alpinejs)

## Written by

[Anjanesh Lekshminarayanan](https://hashnode.com/@anjanesh)

@anjanesh · Navi Mumbai, MH

  
[View profile](https://hashnode.com/@anjanesh)

Web UI Engineer

I am a web consultant from Navi Mumbai. Mainly dealt with LAMP stack, now into Django and getting into Laravel and Cloud. Founder of nerul.in and gaali.in

## Responses 1

Markdown supported · ⌘↵ to post

[Mehdi Yaghoubi](https://hashnode.com/@mehdi9500)

[Nov 5, 2023](https://hashnode.com/posts/replacing-oninput-with-x-mask/638732935cd93cbec20ad862/comment/6547893008e6f2d0c473be9e)

and How to save the value of the masked model in the livewire component to the database. the x-mask:dynamic="$money($input)" is something like 99,100,200 but I need to save 99100200?

[Anjanesh Lekshminarayanan](https://hashnode.com/@anjanesh)

[Nov 5, 2023](https://hashnode.com/posts/replacing-oninput-with-x-mask/638732935cd93cbec20ad862/comment/6547893008e6f2d0c473be9e#reply-65478b7731ab12d0f49f2a20)

I haven't yet got into Livewire but you could do a replaceAll(',', '') on form submit - bad idea if it's repetitive.

Or

```
<script>
    Alpine.data('x-data', {
        get computedValue() {
            return this.myValue.replace(/,/g, '');
        }
    });
</script>

<span x-text="computedValue"></span>
```
