Copy link to clipboard
Copied
Hello, i would like to know if it is possible to change the number format of a field.
Currently i am using the default number format with thousand seperator and 2 decimals and the "€" symbol behind with a space e.g. "12.500,00 €".
In this format an empty field would be totally empty, but i would like to show up "- €" when the field is empty. Is that possible with a custom format?
Thank you very much in advance.
Copy link to clipboard
Copied
As 'Custom format script' use this:
if(event.value == "")
event.value = "- €";
else
event.value = util.printf("€ %,2.2f",event.value);
If you wish to allow only numbers to be entered in field, use this as 'Custom keystroke script':
event.rc = /^\d*$/.test(event.change);
Copy link to clipboard
Copied
As 'Custom format script' use this:
if(event.value == "")
event.value = "- €";
else
event.value = util.printf("€ %,2.2f",event.value);
If you wish to allow only numbers to be entered in field, use this as 'Custom keystroke script':
event.rc = /^\d*$/.test(event.change);
Copy link to clipboard
Copied
Thank you very much, that works perfectly.
I changed the output at else a little bit so that the € is comming behind the number and it works.
event.value = util.printf("%,2.2f €",event.value);
Now the only problem is, that i have a Button to reset all fields.
This Button runs the code
if(4==app.alert("The form will be resetted.\n\nAll data will be removed! Continue?",1,2)) {
this.resetForm(["Field1", "Field2", "Field2"]);
this.getField("top").setFocus();
}
When running this code, the input with the format script outputs the following:
1,#R €
This field should be resetted to the default value which is currently a number (40).
Do i have to change anything?
Copy link to clipboard
Copied
EDIT: was my fail, had a calculation script in the field which causes the error
Copy link to clipboard
Copied
Keep the format settings and add this script as a Validation script in your field:
if (event.value == 0) {event.value = "- €"};
Acrobate du PDF, InDesigner et Photoshopographe

