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

validation script with a range 2.8 to 3.2

sandybb
Registered: Aug 28 2009
Posts: 6
Answered

I am trying to write a validation script with a range 2.8 to 3.2 = true anything else would be false. If false in-act my error code list below which goes to a document level script. I need to write this script generically enough so I can switch out the variables for other text fields.

ValidateChecks("PT23a_Failure", event.target, "PT23a_Failure.Commits", ["Assembly", "SAP_Code"]);

Thanks,

Sandy

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
if(event.value >= 2.8) && (event.value <= 3.2) )DoErrorCode(..)

For AcroForms the entered value is given by "event.value" in the Validate Event. The event object is global so it is not absolutely necessary to pass it into the document level function.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

sandybb
Registered: Aug 28 2009
Posts: 6
Thank Thom,

I cut and pasted it in the console window and tried to run the code, I get a syntax error so I placed another ( in front of the first one and that solved the syntax error.

I want to place this code on the validate tap, run custom validation script correct? List below is the full code I tried running and I am not able to get the error code to engage.


I liked the Stamps Gone Wild it gives me some ideals!!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The code Thom provided can't be used in the console environment, since there's no event involved.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
As noted 'event' is not a valid object when used within the console because there is no 'event' object. For use in the console, you would need to provide a field object and not the 'event'.

For a generalized solution, you could use a user defined function placed at the document level.
function ValidBetween(cValue, cLower, cUpper) {// check that lower limit is less than upper limitif (cLower > cUpper) app.alert('Lower parameter is greater than upper parameter', 0, 0, 'ValidBetween Error');// return logical value of comparisonreturn (cValue >= cLower & cValue <= cUpper);}

You can then use the above function by passing the value to be tested, and the lower and upper limit values.

In the console you would use:
ValidBetween(3, 2.8 , 3.2);
For use in the 'custom calculation for a field, you could use:
if( ValidBetween(event.value, 2.8 , 3.2) ) {// code when value is  => 2.8 and  <= 3.2} else {// code for when value is not between the range}

For use in another field to test the value of a different filed:
var sTestField = 'test field name';if( ValidBetween(this.getField(sTestField).value, 2.8 , 3.2) ) {// code when value is  => 2.8 and  <= 3.2} else {// code for when value is not between the range}

George Kaiser

sandybb
Registered: Aug 28 2009
Posts: 6
OK, thanks I will try that.