• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Text field entry for percentage needs Period (English) or comma (French) in JavaScript

Explorer ,
Apr 02, 2018 Apr 02, 2018

Copy link to clipboard

Copied

I have a FRENCH fillable form, weather the person enters English 1.50  or 1,50 (comma French formatting), when they tab or enter the field the result should be a comma for French. Is there a way the result will be 1,50 whether it is entered as a period or comma?

Currently I have these scripts below if entering a period for English it will convert to comma for FRENCH but when entered as a comma the field becomes blank.

I need to be able to enter either/or in this field and have it convert to comma for FRENCH.

Custom format script

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

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

}else{

  1. event.value = "";

}

But nothing in the Custom keystroke script.

Validate tab, Run custom validate script

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

  1. event.value = event.value / 100 ;

}

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

{

  1. event.value="";
  2. app.alert("L’entrée doit être entre 0 et 100")

}

Thank you in advance! http://

TOPICS
Acrobat SDK and JavaScript

Views

341

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
community guidelines
LEGEND ,
Apr 02, 2018 Apr 02, 2018

Copy link to clipboard

Copied

The easiest way would to format the field as a percentage and chose the "," separator. You may have to explain to the user about the use of the "," decimal point.

If you do not want to do then, then you will have to create a custom keystroke script to intercept and change the "," to a coma and then create a custom validation script to verify the use of the appropriate thousand separator and decimal point along with the custom format script for displaying the formatted result.

Votes

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
community guidelines
Explorer ,
Apr 02, 2018 Apr 02, 2018

Copy link to clipboard

Copied

Unfortunately that doesn't work because it will give me % sign (which I don't need) and it will not allow me to use a period and convert it to comma. See first example.

I need to be able to insert a comma or period and end up with a comma (1,50). My scripts currently work as you can see the last two fields, I entered 1.5 and it converts to 1,5. But if I type 1,5 the field will become blank.

This could be filled out by a English or French speaking person but in the end I need it to be French, with a comma.

Screen Shot 2018-04-02 at 7.27.53 PM.png

What I need is someone that can adjust my scripts below to accept a comma or period and convert to comma.

Maybe I need a Custom keystroke script??

FORMAT/CUSTOM

Custom format script

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

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

}else{

event.value = "";

}

Custom keystroke script.

nothing here

Validate tab, Run 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")

}

Votes

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
community guidelines
Explorer ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

LATEST

Found this and it was very helpful. My problem is solved.

https://forums.adobe.com/thread/1530180

Votes

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
community guidelines