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

Placing an Input Mask on a Multi-Line Text Field

CSDesigner
Registered: Jun 20 2011
Posts: 11
Answered

If possible could I be pointed in the right direction on this site or a head start on how to create a Mask on a text field and allow for Multi-Line entries?

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Just check the field's "multiline" option and then set up the validation mask you want.

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

CSDesigner
Registered: Jun 20 2011
Posts: 11
Ok tr67 thanks for the insight. This is the code I compiled and place in the Custom Validation:
if(event.value == null || event.value == "") {
event.rc = true;
}
else {
if(event.value.match(/^\d{3}-\d{5}$/) == null) {
app.alert("Please enter your account number(s) in the proper format.");
event.rc = false;
}
else
event.rc = true;
}

I am having a problem with my expression, as I want to have the 999-99999 as the mask, what am I missing.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Works fine for me. What exact problem do you have with it?

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

CSDesigner
Registered: Jun 20 2011
Posts: 11
It is giving an error with the proper mask format being input.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
What exact input are you entering?
By the way, why do you need a multi-line text field for this input?

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

CSDesigner
Registered: Jun 20 2011
Posts: 11
I have asked the same question. I would seem the form is internal and the need to input multiple account numbers was the thought but having multiple fields for entry would seem a better use of the form.

As far as the input I would want the mask to be as I stated above.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
The mask you specified above can't be used for multiple values. It will only accept a single code.
You will need to write a more complex validation script to achieve that.

- 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
I think you are using the wrong syntax for the RegExp match/test method. You can also allow the use of ".", " ", or no separator and then adjust the entry to the proper format.

You need to put the RegExp expression before the 'match' or 'test'. For a single account number you can use:

// test for a non-blank entry
if(event.value != "") {
// has a value
// define RegExp for testing value
var REG_AcctNo = /^(\d{3})[ -.](\d{5})$/;
var REG_AcctN = /^(\d{3})(\d{5})$/;
// test input value using the RegExp
if(REG_AcctNo.test(event.value) | REG_AcctN.test(event.value)) {
// valid account number so fix format
event.value = RegExp.$1 + "-" + RegExp.$2;
} else {
// not a formatted account number
app.alert("Please enter your account number in the proper format\n\"999-99999\"", 1, 0, "Format Error");
this.getField(event.target.name).setFocus();
event.rc = false;
} // end RegExp test
} // end has value

For multiple account numbers, you will need to code a way to split the input into individual values and test each value separately. You may also want to make it clear which account number or numbers that need to be adjusted.

I have found it is easy to start with the simplest variation of a problem and then work on the more complex pieces of it once I have the simplest occurrence correct

George Kaiser

CSDesigner
Registered: Jun 20 2011
Posts: 11
Thank you gkaiseril I will try this. And yes I believe that the use of a separator is probably the issue. I also appreciate the input as I didn't think through adjusting for inputs without the dash or separator.