Copy link to clipboard
Copied
All of the placeholder text I worked with in form fields has relied on a custom format script, but now I want to have a placholder of 0 for a field I want to be formatted with a currency symbol and commas (but no decimal points). If I use the custom format to achieve the placeholder with an if/else event.value, what code can I add to it to format the text with a dollar sign, commas and no decimals? I suspect it involves util.printf but I'm a little stuck as to how to actually write it.
Again, you don't need to mess around with a custom Format script. It's not needed.
You just need to use the On Focus and On Blur events.
Copy link to clipboard
Copied
Do you mean that you want to format the value if it's not "0"?
Copy link to clipboard
Copied
I want to have a placholder that reads "$ 0" and then when text is entered, I want it to read as "$ 1,000,000"
Copy link to clipboard
Copied
Just set the default value as "0", then, and use the built-in Number format setting... You don't need any scripts.
Copy link to clipboard
Copied
I did that at first, but it leaves a 0 in the field when you click in and I'd prefer to have it disappear so the user doesn't have to either delete it or account for it in their entry.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I've used this precise resource before, it's helped me many times! However, I can't figure out how the code will support both the disappearing text AND formatting the number in the way that I would like inside of the custom format script.
Copy link to clipboard
Copied
The formatting is done by the option you select in the Format tab. You don't need to do it the code.
Copy link to clipboard
Copied
But if I use a custom format script in the format tab in order to achieve the placeholder text, I can't also use currency formatting, correct? Or am I massively missing something?
Copy link to clipboard
Copied
Again, you don't need to mess around with a custom Format script. It's not needed.
You just need to use the On Focus and On Blur events.
Copy link to clipboard
Copied
Holy MOLEY, I hadn't noticed that the On Focus/On Blur part controlled anything beyond the color (which I don't need here, so I had been ignoring that bit). Thank you so very much for your patience, that is a much less hectic way to set up the field than using a util.printf to achieve formatting that is already built-in.