DEV Community 👩‍💻👨‍💻

Cover image for how to give number format to a input box text while I am typing it
Carlos Alberto
Carlos Alberto

Posted on

how to give number format to a input box text while I am typing it



<br>
function format_num(id) {<br>
var number = document.getElementById(&quot;principal&quot;).value;<br><br>
var checkedNew = number.split(&#39;.&#39;).join(&quot;&quot;);<br><br>
document.getElementById(&quot;principal&quot;).value = checkedNew.toString().replace(/\B(?=(\d{3})+(?!\d))/g, &quot;.&quot;);<br><br>
}<br>














Top comments (0)

🌚 Life is too short to browse without dark mode