This is my input
Is it possible to only allow users to enter
It can be achieved using javascript with corner case handling using toLocaleString()
function getChange(){
// 48 - 57 (0-9)
var str1 = valueRef.value;
if((str1[str1.length-1]).charCodeAt() < 48 || (str1[str1.length-1]).charCodeAt() > 57){
valueRef.value = str1.substring(0,str1.length-1 );
return;
}
// t.replace(/,/g,'')
let str = (valueRef.value).replace(/,/g,'');
let value = +str;
valueRef.value = value.toLocaleString();
}
Working Codepen Demo Link