Participant
October 12, 2023
Question
Auto resize font with a default starting size
- October 12, 2023
- 1 reply
- 427 views
Hi! I have this script to set a default size (12pt) for my field "Name" but have it resize when it reaches the character limit (28) I set. However it is not working. I entered the code into the 'Documents JavaScripts' panel. I can't tell what could be the issue here? Multiline is off but even with it on it doesn't work.
var threshold = 28; // Change this to your desired threshold var standardFontSize = 12; // Change this to your desired standard font size function formatNameField(event) { var fieldValue = event.value; if (fieldValue.length > threshold) { event.target.textSize = 0; } else { event.target.textSize = standardFontSize; } } this.getField("Name").setAction("Format", formatNameField);