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

Numbers in form Fields only

Abbica
Registered: Feb 4 2009
Posts: 38

Hi I have a text field on my form. I just want to be able to type in numbers, not text and I found this code, which I thought might work but it didn't.
 
var patt1=new RegExp(/^\d*$/);
event.rc = patt1.test(event.value);
 
The properties panel will also not let me select an action of numbers.
 
Does anybody know how or what script I use in teh validate script section to get this functioning please?

smit462
Registered: May 20 2006
Posts: 20
You can't simply use the drop-down menu in the "Format" tab of the "Text Field Properties" box?

STEVE MITTEL
Senior Forms Designer
Texas Comptroller of Public Accounts

Abbica
Registered: Feb 4 2009
Posts: 38
Hi, I tried that after I unclicked multi-line which was stopping me and gave it no decimal places as people will be entering in account numbers etc, numbers up to 30 in some cases, but the seperator style give commas and full stops which I don't want, I just want a row of numbers
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Where did you place that code, exactly? It's less than ideal, but should work somewhat as a Validate script, but not as you want it to. I'd normally use a Keystroke script for this, something like the one shown here: http://forums.adobe.com/message/3153643#3153643

An advantage to this approach over the built-in Number format is it prevents the entry of negative numbers, the decimal separator, and digits to the right of the decimal separator.
Abbica
Registered: Feb 4 2009
Posts: 38
Hi George, did the scrips but one thing I didn't understand was:-

Use the following as the text field's custom Keystroke script:

// Keystroke script

Dig09_ks();


I went to document javascripts, named it numbers, added in the code you gave and I am at a loss as to what to do next?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
To enter a custom Keystroke script, set the Format type of the field to Custom and you see where you can enter the Keystroke script.

Just enter the following for the script:

Dig09_ks();


This will call the function you created whenever the user enters data in the field.