Is the script from the same server or at least from the same TS version?
Did you copy the entire script or just a piece of it? It might be doing other things that you haven't copied over.
Is the form structure the same? It's possible that the validation is triggered properly if an item is at the root, but not 3 containers deep.
Can I set the value for selected option in same way item.getOptions()[item.setValue()].value