3

I couldn't find any answer to my problem. I have an input with type="number" and I want the number to automatically add dots to it when it goes up to 1000. So instead of 1000 it should output 1.000, is there a possibility to do that? Like adding some attribute to the input?

Jongware
  • 22,200
  • 8
  • 54
  • 100
carlpoppa
  • 115
  • 1
  • 10

1 Answers1

2

You can use Javascript to add them. Try this plunker: http://plnkr.co/edit/rsTCO8hmZUSEtrvpuWE6?p=preview

If you just need one dot a simple way would be this:

  <input type="number" onkeyup="oneDot(this)"/>

And in JS:

  function oneDot(input) {
    var value = input.value,
        value = value.split('.').join('');

    if (value.length > 3) {
      value = value.substring(0, value.length - 3) + '.' + value.substring(value.length - 3, value.length);
    }

    input.value = value;
  }
arsuceno
  • 46
  • 3