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

Validate Text Field

Mr_adams13
Registered: Jun 2 2010
Posts: 8

I am new to this type of validation. I have been watching videos and going through tutorials but have not been able to figure out how to accomplish this validation

I am using Acrobat pro to create this form.

I have a text box "acctNum" that I need to validate. below are possible acctNum variations
# = any munber
* = number or letter
no special characters allowed.

There are three possible parts to the acctNum each seperated by a "." the first two parts are required but not the third. I suggested to the powers that be to have three fields but they decided they want a single field.

busUnit.objAcct.sub
Samples 11689.23658.02 or 2031H603.23679 or 450.36106.1006 and so on...

busUnit variations (required)
####*###
#######* (for the prior two variations busUnit can not have letters in both places. its one or the other or neither)
#####
4500
450
##
#

objAcct (required)
#####

Sub (optional)
####
##

I will probably use this validation on several different forms so any help would be greatly appreciated.
Thank you,
Mike

LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You want to validate input against several different possible formats? This is a bit difficult for the default options. The only way that you can do this is by using a regular expression in a script. Are you familiar with Regular Expressions?

There is an article on this topic here:
http://www.acrobatusers.com/tutorials/text-matching-regular-expressions

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

Mr_adams13
Registered: Jun 2 2010
Posts: 8
Sorry, I should have explained that I realize this validation can not be done using default options and I am not familar with validating dating using scripts. I can accomplish this using VBA but obviously that is not the same.

I was hoping someone could pass along a script that would accomplish the validation.

Thank you

LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
We'll pass along very simple scripts and samples to help users solve there issues, and provide direction, but the forum isn't for providing free custom development. If you can program in VBA then JavaScript should not be too difficult.

So you created this form in Acrobat 9. Did you also use LiveCycle Designer in the process? Acrobat has two different forms technologies. They have very different scripting models. If you've created a LiveCycle form then you may have a simpler option for field level validation.

To get a better view of the Acrobat forms environment you may want to watch the free videos at this site:
http://www.pdfscripting.com/public/34.cfm#FirstForm

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

Mr_adams13
Registered: Jun 2 2010
Posts: 8
This appears to me to be more than just basic scripting. Livecyle did not appear to be any more helpful for this type of validation. I am not asking anyone to custom develop my form I am simply asking those more talented than me in this area to help with one aspect. An aspect I have never had the need to use and probably won't again as the forms I typically create are much more simple and usually are just a fillable version of a word doc. Having a script that accomplishes this validation would go allow way to helping me understand a small portion of what is actually possible

If anyone out there can help, i would very much appreciate it.

Thank you

LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To perform this validation you're going to need to use a a set of regular expressions to describe the different formats. Unless I know the form technology you're using I can't give you any more specific advice. But These articles might help:

http://www.acrobatusers.com/tutorials/text-matching-regular-expressions

Here's a general article on validation:
http://www.pdfscripting.com/public/department46.cfm

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

Mr_adams13
Registered: Jun 2 2010
Posts: 8
LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

That Basic Acroforms Toolset is pretty cool, but none of the types works for this porpose. I can definately use them for the more simple forms I create.

LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In a LiveCycle for the last value evaluated in the validate event script is the value of validation. A false value causes the validation message to be displayed, but does not automatically affect the value. If you need something else to happen you have to put it into script. For example deleting the current value or forcing the user to enter a valid value before moving on.

But just to use the basics you might want to do something like this:
/^\d{5}$/.test(this.rawValue) || /^\d{7}\w$/.test(rawValue) || ... other acntNum tests ... ;
Just write one regular expression for each valid format, or for a group of related formats. The code returns true if the field input matches any one of the valid formats.

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

Mr_adams13
Registered: Jun 2 2010
Posts: 8
/^\d{5}$/.test(this.rawValue)
can you explain what this means...what is it actually doing? where can I find what the characters mean?

Thank you

LiveCycle Designer ES 8.2 / Windows XP Pro 2002 SP3

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Quote:
^\d{5}$/.test(this.rawValue)
test the 'this.rawValue' for being 5 numeric digits.

[url=http://www.w3schools.com/jsref/jsref_obj_regexp.asp]JavaScript RegExp Object[/url]
[url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp]RegExp[/url] Mozilla

If you can find a copy of John Deubert's Extending Acrobat Fromm's with JavaScript, you might want to purchase it. It is written for Acrobat forms but has a number of chapters about using the RegExp for keystroke, format, and validation.

George Kaiser

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There is a link to an article on using regular expressions in my previous post.

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