加号作为千位分隔符,但在每个数字点后面加一个点



hello我必须使用point作为千位分隔符。如果您在输入字段中输入数字,则必须实时显示。数据类型为整型。问题是该函数在每个数字后面加上点。

function numberDots(x) {
return x.toString().replace(/B(?=(d{3})+(?!d))/g, ".");
}
<div class="form-group">

<input type="text" asp-for="inputfield" class="form-control  text-right" onkeyup="this.value=numberWithDots(this.value);"/>
<span  asp-validation-for="inputfield" class="text-danger"></span>
</div>

这是我的代码。我想要这个:222.222但是我得到这个:2.2.2.222

你能帮帮我吗?

像这样修改你的js:

function numberWithDots(x) {         
return x.toString().replace(/^0+/, '').replace(/D/g, "").replace(/B(?=(d{3})+(?!d))/g, ".")            
}