Skip to main content
Participating Frequently
February 14, 2025
Question

Creating scripts in Adobe forms.

  • February 14, 2025
  • 2 replies
  • 760 views

I'm not the greatest at writing scripts. I've inherited a form that I'm trying to update and I could use some help.  

1. In one of the fields, they will be scanning a barcode and the scan will have an equal sign at the beginning of the scan and two zeros at the end of the scan (e.g. =W28132020546700) that I need a script that will automatically delete those in the field. Final result would look like this W2813 20 205467

2.  In another field I have the age. I need a script that will use the DOB field to calculate the age in the AGE field.

3. in another field, they will be scanning an expiration date. The scan will display something like this "

&>0253652359" but I need a script that will convert that to 12/31/2025 23:59.

4. Then lastly, I need a script that will take another scanned value (e.g. =<E0713V00) and remove the leading =< and the trailing 00 and just display E0731.

 

I know it's a lot to ask but I could really use some help. 🙂

 

Thanks!

 

Val

2 replies

Nesa Nurani
Community Expert
Community Expert
February 14, 2025

For number 1, try something like this as custom format script:

if (event.value) {
 event.value = event.value.replace(/^=/, "");
 event.value = event.value.slice(0, -2).replace(/^(W\d{4})(\d{2})(\d+)$/, "$1 $2 $3");}
LEVELHEADAuthor
Participating Frequently
February 14, 2025

I can't figure out why...when I put that script in there and click OK, it doesn't save the information. 😞

PDF Automation Station
Community Expert
Community Expert
February 14, 2025

You should ask each question in separate posts.  For point one, is that a field value?

LEVELHEADAuthor
Participating Frequently
February 14, 2025

It is a Text Field

PDF Automation Station
Community Expert
Community Expert
February 14, 2025

Enter the following custom calculation script:

var aray=event.value.split("");
if(aray[aray.length-1]=="0"){aray.pop()};
if(aray[aray.length-1]=="0"){aray.pop()};
event.value=aray.join("").replace("=","");