A Javascript library without a dependency of jQuery, Zepto, and etc ... Very simple to install and use. With only 1kb (gzip) code, IE Compatibility, it's also well accepted on mobile devices
Add Maskfy file
<script src="https://cdn.rawgit.com/figuarnieri/maskfy/master/maskfy.js"></script>
or
<script src="path/js/maskfy.es5.js"></script>
Insert a selector in class tag
<input class="page--input" data-maskfy="999.999.999-99" type="text" placeholder="CPF (Ex.: 999.999.999-99)">
or
<input class="page--input mask-by-class" type="text" placeholder="CPF (Ex.: 999.999.999-99)">
<script>
new Maskfy({
tag: '[data-maskfy]', //{String: undefined} (required) selector input
mask: '999.999.999,99', //{String: undefined} (required) input mask pattern
reverse: false, //{Boolean: false} reverse typing
minSize: 3 //{Boolean: false} minimum digits
defaultValue: '123' //{String: undefined} initial value
letters: true //{Boolean: false} allowed letters
after: (input) => console.log(input) //{Function: undefined} after input event
});
</script>
If necessary, you could add attributes in the tag, to configure your mask options
<input data-maskfy="999.999.999,99">
<input data-maskfy="999.999.999,99" data-maskfy-reverse="true">
<input data-maskfy="999.999.999,99" data-maskfy-reverse="true" data-maskfy-minsize="3">
<input data-maskfy="999-9999" data-maskfy-letters="true">
<input data-maskfy="999.999.999,99" value="123.456.789,01">
The MIT License
Copyright 2018 © Filipe Guarnieri