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

Saage abi kiiremini ja hõlpsamalt

Uus kasutaja?

Adobe MAX 2024

Adobe MAX
Loovuse konverents

14.–16. oktoobril Miami Beachis ja veebis

Adobe MAX

Loovuse konverents

14.–16. oktoobril Miami Beachis ja veebis

Adobe MAX 2024

Adobe MAX
Loovuse konverents

14.–16. oktoobril Miami Beachis ja veebis

Adobe MAX

Loovuse konverents

14.–16. oktoobril Miami Beachis ja veebis