Copy link to clipboard
Copied
hello, i use this on Text field :
event.value = event.value.replace(/\,AbAb/g, "1234");
program check if AbAb and replace it with 1234
how to run only one time this loop? and if i write again AbAb the keep AbAb ??
Ok so if you want the loop to run more times then change the length like this....
var check = 0;
if (check < 4){
event.value = event.value.replace(/\,AbAb/g, "1234");
check++;
}
Or depending on how and where you are running this from do like Bernd Alheit​ said and check multiples like this...
...var checkFieldOne = 0;
var checkFieldTwo = 0;
var checkFieldThree = 0;
var checkFieldFour = 0;
var checkFieldFive = 0;
if (checkFieldOne == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
chec
Copy link to clipboard
Copied
It's not possible within that code itself. You will need to keep some kind of external marker for when it should (or shouldn't) replace that string.
Copy link to clipboard
Copied
any example about that?
Copy link to clipboard
Copied
Not sure if this will help you but.... maybe something like this??...
I guess it depends on where/how you run your script.
var check = 0;
if (check == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
check++;
}
Copy link to clipboard
Copied
hi subieguy2 this answer work for 1 field...
i have 5 text fields and i want to restart this loop for every new field... for now on text field 1 work but when i go to text field 2 not work because check has value 1.
Copy link to clipboard
Copied
Use check1, check2, and so on for the fields.
Copy link to clipboard
Copied
Ok so if you want the loop to run more times then change the length like this....
var check = 0;
if (check < 4){
event.value = event.value.replace(/\,AbAb/g, "1234");
check++;
}
Or depending on how and where you are running this from do like Bernd Alheit​ said and check multiples like this...
var checkFieldOne = 0;
var checkFieldTwo = 0;
var checkFieldThree = 0;
var checkFieldFour = 0;
var checkFieldFive = 0;
if (checkFieldOne == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
checkFieldOne++;
}
if (checkFieldTwo == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
checkFieldTwo++;
}
if (checkFieldThree == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
checkFieldThree++;
}
if (checkFieldFour == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
checkFieldFour++;
}
if (checkFieldFive == 0){
event.value = event.value.replace(/\,AbAb/g, "1234");
checkFieldFive++;
}
If this doesn't get you what you are looking for I would suggest posting more details about your document and how you want it to be used. Or better yet share a file and we can help try to get your questions answered.