Is there a method available to automatically insert commas into an input type="number"
field in vue js? I need this functionality to trigger the IME options in Microsoft and prevent users from inputting Japanese characters.
<ui-textbox label="initial" v-model="initial_cost"
name="initial_cost"
v-validate="`numeric|decimal`"
type="number"
v-on:keydown="isNumber"
:maxlength = "18"
:enforceMaxlength="true"
value = 0.00
format="number"
></ui-textbox>
isNumber: function(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
var charval= String.fromCharCode(evt.keyCode);
console.log(typeof evt);
if((charCode >= 48 && charCode <= 57) || (charCode >= 96 && charCode <= 105) || charCode == 8 || charCode == 46 ||
charCode ==36 || charCode ==35){
return true;
}else{
return false;
}
If the user enters 1000
, the display should show 1,000
, 10000
as 10,000
, and so forth. I came across a solution to a similar issue here, but it seems like they are using an input type="text"
field. Is there a way to implement this for my type="number"
field in vue?