Add IMask library for currency input formatting
- Menambahkan dependensi IMask pada file package.json. - Mengimpor IMask ke dalam file app.js dan membuatnya tersedia di global (window.IMask). - Mengimplementasikan format input mata uang menggunakan IMask pada elemen dengan class "currency".
This commit is contained in:
parent
71caad2544
commit
9cfe7d1cda
@ -23,6 +23,7 @@
|
|||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
"esri-leaflet": "^3.0.12",
|
"esri-leaflet": "^3.0.12",
|
||||||
"esri-leaflet-geocoder": "^3.1.5",
|
"esri-leaflet-geocoder": "^3.1.5",
|
||||||
|
"imask": "^7.6.1",
|
||||||
"jquery": "^3.7.1",
|
"jquery": "^3.7.1",
|
||||||
"mini-svg-data-uri": "^1.4.4",
|
"mini-svg-data-uri": "^1.4.4",
|
||||||
"notie": "^4.3.1",
|
"notie": "^4.3.1",
|
||||||
|
@ -6,6 +6,7 @@ import Swal from "sweetalert2";
|
|||||||
import TomSelect from "tom-select";
|
import TomSelect from "tom-select";
|
||||||
import toast from "toastr";
|
import toast from "toastr";
|
||||||
import "toastr/build/toastr.css";
|
import "toastr/build/toastr.css";
|
||||||
|
import IMask from "imask";
|
||||||
|
|
||||||
window.jQuery = $;
|
window.jQuery = $;
|
||||||
window.$ = $;
|
window.$ = $;
|
||||||
@ -13,6 +14,8 @@ window.$ = $;
|
|||||||
window.Swal = Swal;
|
window.Swal = Swal;
|
||||||
window.swal = Swal;
|
window.swal = Swal;
|
||||||
|
|
||||||
|
window.IMask = IMask;
|
||||||
|
|
||||||
document.querySelectorAll(".tomselect").forEach((el) => {
|
document.querySelectorAll(".tomselect").forEach((el) => {
|
||||||
let settings = {
|
let settings = {
|
||||||
plugins: ["dropdown_input"],
|
plugins: ["dropdown_input"],
|
||||||
@ -75,3 +78,19 @@ window.formatRupiah = function (angka) {
|
|||||||
});
|
});
|
||||||
return formatter.format(angka);
|
return formatter.format(angka);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
document.querySelectorAll(".currency").forEach((el) => {
|
||||||
|
IMask(el, {
|
||||||
|
mask: Number, // enable number mask
|
||||||
|
|
||||||
|
// other options are optional with defaults below
|
||||||
|
scale: 2, // digits after point, 0 for integers
|
||||||
|
thousandsSeparator: ".", // any single char
|
||||||
|
padFractionalZeros: false, // if true, then pads zeros at end to the length of scale
|
||||||
|
normalizeZeros: true, // appends or removes zeros at ends
|
||||||
|
radix: ",", // fractional delimiter
|
||||||
|
mapToRadix: ["."], // symbols to process as radix
|
||||||
|
|
||||||
|
autofix: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user