Hi Guys,, I'm trying to make format currency in Indonesian using javascript but why the textbox not firing when keyboard pressed.if this code running in html working properly, but not in ASP.NET. Anny help could be appriciate.
Currency Format in Javascript
C#
">
$(document).ready(function () {
function FormatRupiah() {
var input = document.getElementById("");
input.addEventListener('keyup', function(e)
{
var number_string = bilangan.replace(/[^,\d]/g, '').toString(),
split = number_string.split(','),
sisa = split[0].length % 3,
rupiah = split[0].substr(0, sisa),
ribuan = split[0].substr(sisa).match(/\d{1,3}/gi);
if (ribuan) {
separator = sisa ? '.' : '';
rupiah += separator + ribuan.join('.');
}
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
});
}
});Code Bihind
C#
protected void Page_Load(object sender, EventArgs e)
{
txtCurrency.Attributes.Add("onkeyup", "FormatRupiah(this)");
}

Sachin SinghRank #66 · 26.2K reputationPosted Jun 15, 2021, 12:22 PM EDT
Salman BegRank #284 · 8.8K reputationPosted Jun 15, 2021, 1:00 PM EDT
Tri SetiaRank #4,571 · 337 reputationPosted Jun 16, 2021, 1:14 AM EDT