If you want something generic, in which masks can be applied to various patterns
<script>
function format(mask, number) {
var s = ''+number, r = '';
for (var im=0, is = 0; im<mask.length && is<s.length; im++) {
r += mask.charAt(im)=='X' ? s.charAt(is++) : mask.charAt(im);
}
return r;
}
console.log(format('XXXX.XXXX.XXXX-X', 1234213412341)); // esse primeiro é o que vc quer
console.log(format('XX/XX/XX/XX/XX/XX,X', 1234213412341));
console.log(format('XX muito XX manero XX.XX.XX.XX.X', 1234213412341));
</script>
source: https://stackoverflow.com/a/14231497/1685571
@And I love the system so much camelCase. :)
– Zuul
I also prefer :p only edited on account of the name I was calling on Alert, if it is wrong can reverse the edition.
– Renan Gomes
@You did well, leave it at that!
– Zuul