Make a field visible dependent on another fields length - Issue change event

Avatar

Avatar

deboraha5380687

Avatar

deboraha5380687

deboraha5380687

04-12-2019

Hi all,

I want to make a field named "KdAufPos" visible, if another field named "Kontierungselement" (text field) has the character length 7.

I am using the following javascript code in the change event of the Kontierungselement field:

 

console.println("START ");

var currentLength = this.rawValue.length;

var kdAufPos = FormServiceRequestConfirmation.mstPageSet1.mstPage1.frmTitle.KdAufPos;

console.show();

console.println("currentLength "+ currentLength);

 

validateFieldValueLength(currentLength);

function validateFieldValueLength(currentLength){

if (currentLength == 7 ){

console.println("zeichenlänge momentan " + currentLength);

kdAufPos.presence = "visible";

}else{

console.println("KdAufNr ist nicht leer " + currentLength);

}

}

My issue is that the change event is not triggering correctly. After I am opening the PDF and entering data in the field, the console is showing up but don't display my console.println - I got an error with "TypeError: this.rawValue is null".

1861278_pastedImage_12.png

Just after exit the field and click in again, I got the console.println and got displayed sometimes the right and sometimes the wrong length...

What is this error about? Why is it that after clicking out and in again the script seems to work and at least do something?

Any tips?

Thanks a lot!

Regards

Deborah

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar

deboraha5380687

Avatar

deboraha5380687

deboraha5380687

09-12-2019

Hi Bruce BR001​,

how to use the xfa.event.newText event? Do you have an example?

So in which standard Adobe events (initialize, change, validate...) do I have to put my code in?

Thanks & regards

Deborah

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

05-12-2019

Hi Deborah,

You are getting the exception because this.rawValue is null and the null object does not have a length property.

In the change event this.rawValue has not been updated yet.

You probably want to use xfa.event.newText instead.

Regards

Bruce