title: html Input type number with Thousand Separator
body: <p>i want to add thousand separator on keyup event in input type number
  but this work just in 6 character, if more than 6 character, value on input has reseted </p>
  
  <p>this my short code</p>
  
  <pre><code>&lt;input type="number" id="tanpa-rupiah" step="any"&gt;
  
  
  
  var dengan_rupiah = document.getElementById('dengan-rupiah');
      dengan_rupiah.addEventListener('keyup', function(e)
      {
          dengan_rupiah.value = formatRupiah(this.value, 'Rp. ');
      });
  
  
   function formatRupiah(bilangan, prefix)
  {
      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></pre>
  
  <p>this my fiddle <a href="https://jsfiddle.net/C2heg/4619/" rel="nofollow noreferrer">https://jsfiddle.net/C2heg/4619/</a></p>