Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Numeric field format

Avatar

Former Community Member
I am new to Acrobat and designing in LiveCycle 8.0.



My first try worked very well. It is a survey that takes numeric input from the user and calculates averages and sums for a total score. I must say I am very impressed.



What I need assistance on is this.



I want the user to only be able to put:

1. Numbers

2. Limit the numbers to 1 thru 10

3. All number input boxes must be filled.



Thanks in advance for your help.



Lynn



PS...My next challenge will be to have the data stored into SQL. If you know of any good tutorials for this please let me know.
5 Replies

Avatar

Former Community Member
Hi Lynn,



1. Numeric fields will only retain numeric values. Nothing to do here.

2. To limit the numbers, write a validation script. For example:

a. Select the numeric field

b. Go to the Script Editor and select the validate event from the Show list. Select JavaScript as the Language type. If the Script Editor is not opened, go to the Window menu and select Script Editor. It will show up at the top of the application window.

c. Type the following JavaScript:



(this.rawValue > 0 && this.rawValue < 11);



d. Keep the field selected, go to the Object palette, Value tab.

Type a Validation Script Message. This message will be displayed every time the validation script fails.



3. In the Object palette, Value tab, you can set the Type to User Entered Required. The end-user will not be able to submit the form unless every required field is filled.



Regards,



Hélène

Adobe Systems

Avatar

Former Community Member
Thanks Hélène,



The script works great but it still takes the input of numbers 11 and beyond with an error screen like "A1 validate failed".



Ideally we would like it to not allow the number out of the parameters and return them to enter a correct value.



Thanks again for you reply.

Avatar

Former Community Member
Hi Lynn,



Try the following JavaScript on the exit event of the numeric field. Note it will reset the field's value if it's not between 1 and 10 (I wasn't sure if you wanted to do this or not).



if ( (this.rawValue < 1) || (this.rawValue > 10) )

{

this.rawValue = null;

xfa.host.messageBox("Please enter a value between 1 and 10.", "Invalid Value", 0, 0);

xfa.host.setFocus(this.somExpression);

}



Does this correspond to your requirement?



Hélène

Adobe Systems

Avatar

Former Community Member
Thanks again Hélène



Yes that is how we wanted it to perform.



One other question? How do we know where the "Exit" event is located and to input the JavaScript you so kindly provided?



Thank you so much for your help and quick responses,



Lynn

Avatar

Former Community Member
Good : )



You can write the script as follows:



1. Select the object.

2. Go to the Script Editor. If it's not opened, go to the Window menu and select Script Editor. It will show up at the top of the application window.

3. Select the exit event from the Show drop-down list. Then select JavaScript from the Language drop-down list.

4. Type the script in the editor.

5. Preview the form.



Let me know how it goes.



Hélène

Adobe Systems.