Skip to main content
Known Participant
September 10, 2021
Question

Zip code JavaScript

  • September 10, 2021
  • 2 replies
  • 726 views

Greetings,

Is there a way to do pdf JavaScript in order to just write the zip code and get the State & cities automatically?

Thanks!

    2 replies

    try67
    Community Expert
    Community Expert
    September 10, 2021

    Yes, it's possible, but you'll need to hard-code (or use a data-source, like a text file) all of the zip-codes and their corresponding cities and states into your code.

    Known Participant
    September 10, 2021

    I appreciate your quick response to my inquiry for information, can you please help with small example of 4 or 5 zip code?

    try67
    Community Expert
    Community Expert
    September 10, 2021

    Here's a simple example, to be used as the custom validation script of the Zipcode field:

     

    if (event.value>=10001 && event.value<=10314) {
    	this.getField("City").value = "New York";
    	this.getField("State").value = "NY";
    } else if (event.value>=12202 && event.value<=12210) {
    	this.getField("City").value = "Albany";
    	this.getField("State").value = "NY";
    } else {
    	this.getField("City").value = "";
    	this.getField("State").value = "";
    }
    LinSims
    Community Expert
    Community Expert
    September 10, 2021

    Please let us know which program you are having problems with. Someone will be along to move this post to the appropriate product forum, where you are more likely to get an answer to your question.

    The Using the Community forum is for help in using the Adobe Support Community forums, not for help with specific programs. Product questions should be posted in the associated product community.