Working with xfa.event.change in JavaScript (LiveCycle Designer)

Issue

If you are working with xfa.event.newText and trying to limit the fields, as demonstrated in the following code, you will find that this will not work.

console.show(); console.println("new text is: " + xfa.event.newText); console.println("old text is: " + xfa.event.prevText); console.println("new text length: " + xfa.event.newText.toString().length); if (xfa.event.newText.toString().length > 9) { console.println( "new text is longer than 9"); this.rawValue = xfa.event.prevText; } console.println("");

You may try to change:

this.rawValue = xfa.event.prevText

to

xfa.event.newText = xfa.event.prevText

but this will still not work to limit the TextField to 9 characters.

Solution

Here is the working code, highlighting the code changes to make limiting the TextField to 9 characters work:

console.show(); console.println("new text is: " + xfa.event.newText); console.println("old text is: " + xfa.event.prevText); console.println("change is: " + xfa.event.change); console.println("new text length: " + xfa.event.newText.toString().length); if (xfa.event.newText.toString().length > 9) { console.println("new text is longer than 9"); xfa.event.change = ""; } console.println("");

 Adobe

更快、更輕鬆地獲得協助

新的使用者?

Adobe MAX 2024

Adobe MAX
創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX

創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX 2024

Adobe MAX
創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX

創意大會

10 月 14 至 16 日邁阿密海灘和線上