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

textfield input to only allow values in increments

Jess_Miller
Registered: May 19 2009
Posts: 6
Answered

How do I limit a textfield input to only allow the values in increments?
For Example, I have a text field that requires increments of $50.00, so a user should not be able to put in $75.00.

My Product Information:
Acrobat Pro 8.1, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi Jess_Miller,

There are a lot of ways you could approach doing that. You could use a pulldown list with increments of 50 as choices if you don't have an enormous number of choices. Or you could write a validation script that would blank the field out if it wasn't a multiple of 50 and then alert the user with a message box that it must be in increments of 50. Or you could use a custom keystroke script that would round the value to the nearest increment of 50, you deicde to round up ro down in the script.

So there are a variety of options- you will have to provide more details to get a more specific apporach to a solution.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
Jess_Miller
Registered: May 19 2009
Posts: 6
Thank you so much Dimitri for you reply!
I can not do a combo/list box, the choices are too many! I also do not want to round up, because I want the user to be able to choose, so I think the best thing would be the validation script to blank out the field with an alert message.

I am just learing script, so I am not 'fluent', but I do know a little....Can you give me a sample of what a script would look like ? If the user's would like to order 75 'pennies', I need a script that would notify them that 'pennies' need to be ordered in increments of 50, then the user could decide to order 50 or 100.
Make sense?
Jess_Miller
Registered: May 19 2009
Posts: 6
Well, with a little digging I answered my own question. In case anyone is interested, this is what I did:

I put this script under my Text Field Properties, Validate, Run Custom Validation Script:

if (event.value % 50) {app.beep(0); app.alert("Must be ordered in increments of 50"); event.rc = false;}