Hello, this marks the beginning of my inquiry. I apologize if it comes across as trivial but I have come across this piece of code:
function format(input){
var num = input.value.replace(/\./g,'');
if(!isNaN(num)){
num = num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{1})/g,'$1.');
num = num.split('').reverse().join('').replace(/^[\.]/,'');
input.value = num;
}
else{ alert('Please enter only numeric values');
input.value = input.value.replace(/[^\d\.]*/g,'');
}
}
I am struggling to fully grasp its functionality, but essentially it formats an input in real-time to a pattern like "9.9.9.9.9", whereas I need it to be structured as "9.9.9.9.9.". How can I modify it to add that final period? Thank you in advance.