I am using regex in vuejs to manipulate input field data.
below is the code:
<input
v-model="inputValue"
type="text"
:placeholder="placeholder"
:class="['w-full !border-none !focus:border-none p-2.5 shadow-none', disabled ? 'text-[#969c9f]' : 'black']"
@input="ValidateInput"
:disabled="disabled"
/>
ValidateInput(){
if(this.valueType == "Number"){
this.inputValue = this.inputValue.replace(/[^0-9]/g, '');
}else if(this.valueType == "SP"){
this.inputValue = this.inputValue.replace(/^0+/, '').replace(/D/g, '');
}else if(this.valueType == "Number_with_TS"){
this.inputValue = this.inputValue.replace(/[^0-9]/g, '');
this.inputValue = this.inputValue.replace(/B(?=(d{3})+(?!d))/g, ' ');
}else if(this.valueType == "SP_with_TS"){
this.inputValue = this.inputValue.replace(/^0+/, '').replace(/D/g, '');
this.inputValue = this.inputValue.replace(/B(?=(d{3})+(?!d))/g, ' ');
}else if(this.valueType == "decimal"){
this.inputValue = this.inputValue.replace(/[^0-9.]/g, '');
const parts = this.inputValue.split('.');
if (parts.length > 2) {
this.inputValue = parts[0] + '.' + parts.slice(1).join('');
}
}else if(this.valueType=="ZipCode"){
this.inputValue = this.inputValue.replace(/[^0-9]/g, '');
if (this.inputValue.length > 4) {
this.inputValue = this.inputValue.substring(0, 4);
}
} else if (this.valueType === "disabled") {
this.inputValue = 0;
this.$emit('update:modelValue', this.inputValue);
} else if(this.valueType == "model_spec"){
if (this.inputValue.length > 60) {
this.inputValue = this.inputValue.substring(0, 60);
}
}else if(this.valueType=="cylinder_volume"){
this.inputValue = this.inputValue.replace(/[^d,.]/g, '');
}
if(this.inputValue == ""){
this.inputValue=null;
}
this.$emit('update:modelValue', this.inputValue);
}
above code is working on desktop but not on mobile.
I have tried multiple regular expressions, but they are working on desktop, and not working on mobiles