Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

XDP JavaScript validate text field with leading zero value issue in FR

Avatar

Level 4

I have encountered an issue with JavaScript and showing or hiding a text box.

 

All works as expected in EN but not in FR. The value received in EN is "$0" and the one in FR is "0 $".

 

I am beginning to suspect this may be a bug with a leading zero in a floating text field.

 

Why would it work in EN as per:

 

if (this.rawValue != "$0"){

    xfa.resolveNode("COC.Body.sfBeneLimit.txtBeneLimit").presence = "hidden";

    xfa.resolveNode("COC.Body.sfBeneLimit.txtBeneLimitClause").presence = "visible";

}

 

But not in FR as per, the value received is correct:

 

if (this.rawValue != "0 $"){

    xfa.resolveNode("COC.Body.sfBeneLimit.txtBeneLimit").presence = "hidden";

    xfa.resolveNode("COC.Body.sfBeneLimit.txtBeneLimitClause").presence = "visible";

}

 

Any suggestions on alternate coding to check for 1st character being a zero might work, please suggest the code.

 

Does anyone know if this is a known issue? Has anyone encountered this before? Is there a better solution which I can test?

 

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 4

This solution worked for me:

 

form1.#subform[0].TextField1::initialize - (JavaScript, client)
var str = TextField1.rawValue.substr(0,1);

if (str > 0){

TextField.rawValue = "100";

}

View solution in original post

2 Replies

Avatar

Level 4

What I may require is a simple alternate solution; check the value on exit and if first character is a zero do something else do nothing.

 

Here is a sample of an alternate approach which may work, however, I did not code it properly:

 

form1.#subform[0].NumericField::initialize - (JavaScript, client)
var str = NumericField.substr(0,1);

if (str > 0){

TextField.rawValue = "100";

}

 

With JavaScript can someone write this out so it works?

 

Thank you in advance...

 

 

This worked:

 

form1.#subform[0].TextField1::initialize - (JavaScript, client)
var str = TextField1.rawValue.substr(0,1);

if (str > 0){

TextField.rawValue = "100";

}

Avatar

Correct answer by
Level 4

This solution worked for me:

 

form1.#subform[0].TextField1::initialize - (JavaScript, client)
var str = TextField1.rawValue.substr(0,1);

if (str > 0){

TextField.rawValue = "100";

}