Searching the internet, I found a code that makes weight masks in the field. But this code works with ID criteria.
I would like it to work with CLASS, so I can use it in other fields.
function id(el){
return document.getElementById(el);
}
window.onload = function(){
id('peso').onkeyup = function(){
var v = this.value,
integer = v.split('.')[0];
v = v.replace(/\D/, "");
v = v.replace(/^[0]+/, "");
if(v.length <= 3 || !integer)
{
if(v.length === 1) v = '0.00' + v;
if(v.length === 2) v = '0.0' + v;
if(v.length === 3) v = '0.' + v;
} else {
v = v.replace(/^(\d{1,})(\d{3})$/, "$1.$2");
}
this.value = v;
}
};