3
Searching the internet, I found a code that masks weight in the field. But this code works with ID criteria.
I would like it to work with CLASS, to be able to use 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;
        }
};
.getElementsByClassName()gives a list/array. Just as this will give error... you must have at least [0], iereturn document.getElementsByClassName(el)[0];– Sergio