I want the newValue to keep the maskValue format, with spaces.
I have for example these two strings, the expected outcome would be this:
maskValue: "0 0000 0000 0000" <= initial maskValue
rawValue: "251551220"
As i type the maskValue changes to: "2 5155 1220 0000"
newValue = "2 5155 1220" <= expected result
2 5155 1220 0000 <= current result, it adds the rest of the zeros
This is my code:
const formattedValue = (maskValue.split('').filter(
val => val === ' ' || rawValue.split('').includes(val)
))
.join('');
Thanks for the help in advance