What i usually do is to place the code in the target fiel, not in the source field.
At first get the value from the source field:
var value1 = +getField ("text1").value;
Then do the translation from the number to the text
... convert value1 to text1
And finally assign the text to the current field:
event.value = text1;