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

Maximum = 100 Minimum = 0 value in a field? what is the code please

Abbica
Registered: Feb 4 2009
Posts: 38

Hi, I have a field, which requires you to input a maximum of 100, not anything over. Can someone tell me now to do this please, what is the code and where do I put it please, much appreciated any help.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Although you could create a script for this, you can also use the built-in method that you'll see on the validate tab of the field properties dialog. It allows you to specify the minimum and maximum values for fields with a numeric format.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you looked at the "Validate" tab on the "Properties" pop-up window for the field?

The field needs to have the Number Format, and then the option for the value range will be available.

There is a built in function, AFRange_Validate(bGreaterThan, nGreaterThan, bLessThan, nLessThan), that could also be used.

Or you can use a custom validation script like:

nMin = 0; // greater than or equal to min;
nMax = 1000; // less then or equal to max;
if(event.value < nMin | event.value > nMax) {
app.alert('Invalid value: \n value must be \n\tgreater than or equal to ' + nMin + '\n\tor less than or equal to ' + nMax, 1, 0, 'Validation Error');
event.rc = false;
}

George Kaiser

Abbica
Registered: Feb 4 2009
Posts: 38
Hi, thank you very much for your help. I didn't have the number format selected so couldn't get the option for the value range. But I ended out using your custom validation script as it appears more professional on input of wrong info. Thanks again.