These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Create form with unique entries

thehustleman
Registered: Oct 13 2008
Posts: 11
Answered

I want to create a form that will accept numeric entries (whole numbers) within a given range. Each field must contain a number that was not used previously. I assume that this must be done with JavaScript, can anyone help me or point me in the right direction? I'm using Acrobat pro version 8. Thanks in advance for your help.

My Product Information:
Acrobat Pro 8.1, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, you probably will need to use JavaScript, but you also need to provide a bit more information. How many fields will be used? What is the range of valid numbers. A bit of background about what you're trying to accomplish might be helpful too. The more info the better.

George
thehustleman
Registered: Oct 13 2008
Posts: 11
What I am trying to accomplish is converting an existing form we use at my job for vacation slots. Typically, there are 200-250 fields to fill (with the same amount of valid numbers.) For example, a person may select 33 as a slot, but after selecting a few slots, they make inadvertently use 33 again. I want the form to only allow the field to be filled with a number that has not been used previously in the form. Thank you for your quick reply. :o)
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
There are many ways you could set this up, but the general approach would be to use the field's validate event to call a JavaScript routine that loops through the relevant fields and checks to see if any already contain the value that has been entered, and if so, alert the user and then reject the entry.

If you use a hierarchical field naming scheme for the relevant fields (e.g., slot.0, slot.1,...slot.250), the code can be simplified a bit. Have you done much Acrobat JavaScript programming?

George
thehustleman
Registered: Oct 13 2008
Posts: 11
I have not done any JavaScript programming on any level. Once I get the general idea, I guess I'll have to research the actual JavaScript. Does anyone here have that knowledge?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I've put together a quick demo that I believe illustrates what you want to do: [url=https://share.acrobat.com/adc/document.do?docid=6db00f6d-953d-4d4a-b772-ee623d71c581]Slot Demo[/url]


You'll have to download it and use it locally to test it out. It uses a single document-level function that is called from each of the field's Validate event. The code is fairly well commented, so it should get you started. Note that it does use a hierachical field naming scheme so that the getArray field method can be used. Post again if you have any questions.

George
thehustleman
Registered: Oct 13 2008
Posts: 11
Thanks George! I'll experiment with it for a couple of days and let you know the results. I really appreciate your help!

Update: I will have to tweak the java a bit to fit my need, but this is what I needed. Thank you again for your help!