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

Restrict input data type and range

Starsuni
Registered: Aug 18 2011
Posts: 7
Answered

Hi All,
 
I am new comer on Livecycle Designer. I am now take part of the project, to implement eform in my office.
 
I am stuggling for how to restrict the data type and range when user input.
 
I would like to disallow user to input decimal value in the first table field (Numeric Field). And also restrict user to input value 0-9 in second table field(Numeric Field).
 
Anyone please give me some idea?
 
Thanks a lot.
 
Starsuni

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hi,

the solution is simple.
Just set the data format (under the binding tab) of the numeric field to "integer".
The field then only accepts integers while typing.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Starsuni
Registered: Aug 18 2011
Posts: 7
radzmar

Thanks for your much, It's work.

May I know about the date range? I would like to restrict the user to insert range of value, like 0-10.

Thank you very much

Starsuni
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

with regualar expression you can restrict the input to any value or range you like, but those expression are difficult to understand as they look very muddled.

To allow only numbers from 0 to 10 you can use this script in the change event of the field.
  1. if (!xfa.event.newText.match(/^(1[0]|[0-9])$/)) {
  2. xfa.event.change = ""
  3. }
More about regular expressions can be found in the RegExLib.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Starsuni
Registered: Aug 18 2011
Posts: 7
Radzmar

Sorry for my misleading

I paste the script to under the valiate event, but the error is prmpted when execute.

Error: syntax error near token '/' on line 1, column 30.

Would you please advice
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Use the change event not the validate event.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Starsuni
Registered: Aug 18 2011
Posts: 7
Radzmar

I have changed the event type but the error still occurs.

Starsuni
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Ahhmmm, the language is JavaScript not FormCalc.
Ensure you selected the right one in the script editor.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs