Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Created July 17, 2023 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/b95ca008f087bd1051c63923f76cbe59 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/b95ca008f087bd1051c63923f76cbe59 to your computer and use it in GitHub Desktop.
<div x-data="{
value: {{ value }} ?? '',
displayValue: {{ value }} ?? '',
demaskValue(value) {
this.value = value.replaceAll('$', '').replaceAll(',', '')
}
}" class="-mr-2">
<input
type="text"
x-mask:dynamic="'$' + $money($input)"
:value="displayValue"
@input="demaskValue($el.value)"
placeholder="$0.00"
/>
<input
type="hidden"
name="{{ name }}"
x-model="value"
/>
{{-- for testing purposes --}}
<span x-text="value"></span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment