Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

need pattern to display negative value in red

Avatar

Level 2

I am having one xdp form which contains multiples objects having some textfields mapped with some xsd.

requirement is if values is negative need to display it in red color as  "-$18,970.50"

currently it is getting displayed as   "$-18,970.50"

I have used pattern num{$z,zzz,zz9.99}

Is any ready made format available for this?

3 Replies

Avatar

Level 6

Your requirement ("-$18,970.50") is not so common and may have to do major changes to meet this....I will start using a textField rather than a NumberField and Format using scripting not using out of box functionality. Changing text color to red is easy and can be easily done using scripting again.

I am sure you can try your self if you have some idea about JS or FC scripting....I can help you if you post additional requirements.....like...

1. Is the value prefilled / keyed in / calculated from other fields or combination of one or more?

2. Max and Min value allowed/ expected.

3. Any involvement of user actions there on?

Avatar

Level 2

Thanks Varma,

Actually all data is in prefilllled in xml and xsd mapped with XDP tempalte.

and all fields are readonly.

I am not having much idea about JC and FC scripting.

Could you please give some pointers for same.

Thanks,

Abhijit

Avatar

Level 2

Issue resolved by setting following script in validate action

var num = AMT.rawValue;
if(num < 0){
  AMT.fontColor="255,0,0";
}

  and setting pattern as = num{z$z,zzz,zz9.99}