Hello community:
I'm defining a rule inside the section code schema to remove spaces from a field value when the user tries completes the field "UsrTexto1". It is defined as follows:
methods: {
cambioTexto1: function() {
var vueltas = this.get("Vueltas");
this.set("Vueltas",vueltas+1);
var txt1 = this.get("UsrTexto1");
if (txt1.includes(' ')) {
var txt2 = txt1.replaceAll(' ','');
this.set("UsrTexto1",txt2);
}
},
}
So when the field is modified it searches for spaces inside the text and removes them. This is an example of execution:
1) When the user types the text value
2) After the method is executed:
The problem is that the function is executed too many times. I've added a counter 'vueltas' to show how many times the function is called and here it is the result:
It doesn't make sense as I think that the method should be called exactly 2 times (1st when it removes the spaces, and 2nd when the system detects new changes on the field and now there are no spaces). The main problem is that the whole operation is slowed down because of the high number of calls.
How can I fix this?
Thanks in advance!