From 2d46fa506531b942b0f1cf5567c3e986e9b67652 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Tue, 31 Dec 2024 09:49:40 +0700 Subject: [PATCH] Tambahkan masking input persentase menggunakan IMask - Menambahkan konfigurasi masker input angka untuk elemen dengan class "persen". - Masker mendukung input angka dengan batas 0-100, pemisah ribuan ".", dan delimiter desimal ",". - Memastikan angka diformat dengan benar untuk meningkatkan pengalaman pengguna. --- resources/js/app.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/js/app.js b/resources/js/app.js index 3a46f53..2669077 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -94,3 +94,20 @@ document.querySelectorAll(".currency").forEach((el) => { autofix: true, }); }); + +document.querySelectorAll(".persen").forEach((el) => { + IMask(el, { + mask: Number, // enable number mask + min: 0, + max: 100, + // 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, + }); +});