I am trying to insert separators in my numbers as I type, but for some reason it is not working.
Sample Code
<el-input-number v-model="form.qty" style="width: 100%;" id="test" placeholder="Quantity" controls-position="right" v-on:keyup="handleChange" :min="1"></el-input-number>
methods: {
handleChange: function(value) {
let vm = this;
console.log(value);
const result = value.toString().replace(/\D/g, "")
.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
Vue.nextTick()
.then(function () {
vm.form.qty = result
});
},
}
https://i.sstatic.net/e82hM.png
Problem
Currently, when I enter numbers, no commas are added to the input field, however, when the values are sent to the back-end, they include commas.
Solution Needed
I actually need the opposite behavior from what I described earlier.
- Show numbers with commas in the user interface
- Send numbers without commas to the back-end
Any suggestions?