I need to format a series of numbers with - between each 3 digits.
Possible... I can get some help on this. Thanks!
One could also use the "util.printx" method. No matter which approach one uses, determining the length or value range of the strings will also need to be done.
What ever script you use the "Custom Format" on the "Format" tab. This will only affect the field display and not the actual field value;
Anything that does not actually change the contents of a field, and only affects the formatting would be done in a formatting script. If you want to also constrain what the user can enter, you would have to add a validation script to make sure that only valid characters matching the correct pattern can be entered.
You would get the current value as event.value, which you would modify and then pass back the modified value again as event.value in your custom formatting script.
After many trial and error I get it... in custom format script using this:
event.value = event.value.replace(/(\d)(?=(\d\d\d)+\b)/g,"$1-");
If I want to actually replace the content, not just the display, i'm correct to say I can use this in Custom Keystroke Script Format instead?
It would be best to use a Validate script for that.