number percentage field format needs comma not period

Explorer ,
Mar 28, 2018

Copy link to clipboard

Copied

I have a format custom script.

if (event.value !=="" && !isNaN(event.value)){

event.value = util.printf("%.2f",event.value*100);

}else{

event.value = "";

}

and a custom validation script........

if (event.value !== "") {

event.value = event.value / 100 ;

}

if (event.value>1||event.value<0)

{

event.value="";

app.alert("L’entrée doit être entre 0 et 100")

}

I need my Percentage field to read 1,50 % (French)

Currently it reads 1.50 %  (English)

Any help would be appreciated.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this:

util.printf("%,3.2f",event.value*100);

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

185

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

number percentage field format needs comma not period

Explorer ,
Mar 28, 2018

Copy link to clipboard

Copied

I have a format custom script.

if (event.value !=="" && !isNaN(event.value)){

event.value = util.printf("%.2f",event.value*100);

}else{

event.value = "";

}

and a custom validation script........

if (event.value !== "") {

event.value = event.value / 100 ;

}

if (event.value>1||event.value<0)

{

event.value="";

app.alert("L’entrée doit être entre 0 et 100")

}

I need my Percentage field to read 1,50 % (French)

Currently it reads 1.50 %  (English)

Any help would be appreciated.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this:

util.printf("%,3.2f",event.value*100);

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

186

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 28, 2018 0
Most Valuable Participant ,
Mar 28, 2018

Copy link to clipboard

Copied

Use this:

util.printf("%,3.2f",event.value*100);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 28, 2018 2
Explorer ,
Mar 28, 2018

Copy link to clipboard

Copied

This worded perfectly.

Thank you very much!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 28, 2018 0
Explorer ,
Mar 29, 2018

Copy link to clipboard

Copied

Hello Try67

I was wondering if you could help me a little further with this script.

This is the comment I received back from the Translator on my 1,5 %

If I type a percentage with a comma, the percentage disappears.

If I type it with a period, the percentage converts into French format with a comma.

Could we have it set so that both a comma or a period can be used when typing a percentage and still appear in French format in both cases?

Try67, is this possible?

Again your help would be greatly appreciated.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 29, 2018 0
Most Valuable Participant ,
Mar 29, 2018

Copy link to clipboard

Copied

That would require a custom-made Format and Keystroke script.

On 30 March 2018 at 00:28, marilynr59152174 <forums_noreply@adobe.com>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 29, 2018 0
Explorer ,
Mar 29, 2018

Copy link to clipboard

Copied

Should I post as a new question?

I currently have this Custom format script

if (event.value !=="" && !isNaN(event.value)){

event.value = util.printf("%,3.2f",event.value*100);

}else{

event.value = "";

}

But nothing in the Custom keystroke script.

Validate tab, Run custom validate script

if (event.value !== "") {

event.value = event.value / 100 ;

}

if (event.value>1||event.value<0)

{

event.value="";

app.alert("L’entrée doit être entre 0 et 100")

}

Thanks again

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 29, 2018 0
Most Valuable Participant ,
Mar 30, 2018

Copy link to clipboard

Copied

Basically you would need to replace the comma in the new value with a period to achieve it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 30, 2018 0
Adobe Community Professional ,
Mar 30, 2018

Copy link to clipboard

Copied

app.alert("L’entrée doit être entre 0 et 100")

Ça ne répond pas à la question posée mais tu devrais faire très attention aux caractères accentués dans les messages d'alerte (entre autres).

Il faut absolument que tu lises cet article : https://www.abracadabrapdf.net/?p=633

Sous peine d'obtenir ça :

ascii.png

Au lieu de ça :

unicode.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 30, 2018 0
Explorer ,
Mar 30, 2018

Copy link to clipboard

Copied

Unfortunately that doesn't work.

The person filling out the form may enter 1.5 percentage in English (with period) or 1,5 French (with comma) and the end result should be a French Percentage as it is a French form.

Currently if a French person enters French percentage 1,5 and the tab or enter key the field becomes blank.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 30, 2018 0