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

How to handle zero in a text field set to numeric with a range

kdburley
Registered: Nov 27 2007
Posts: 18
Answered

Hello,

First of all, I am using adobe 8 professional acroform and not a Javascript expert . The problem I am having is with my Javascript code on the submit button. What I am trying to do is loop through all the fields and change the border color to red if the field is missing and required and to black if something been enter. Everything seems to work except on a couple my text fields where I am making it numeric with a range of 0 to 100. When the number zero is enter into these fields the border color is not changing to black. Please let me know if you can help. My code is below:

This code is on my submit button:

app.runtimeHighlight = true;
for(var i=0;i

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Some thoughts:

1. Use paranthesis to order the logical statements for the if.

if( (oFld.required & oFld.value == "") | (oFld.required & oFld.value == "Off") | ( oFld.required & oFld.value == 0) )2. Since you want only to process required fields add an if statement to only allow the testing of required fields:

if (oFld.required) {

if(oFld.value == "" | oFld.value == "Off" | oFld.value == 0)
oFld.borderColor = color.red;
else
oFld.borderColor = color.black;

} // end if required

3. Since Acrobat fields also support the "valueAsString" test all text field as a string and not value.

if (oFld.required) {
oFld.borderColor = color.black; // assume requried and completed

if(oFld.valueAsString == "" | oFld.value == "Off")
oFld.borderColor = color.red; // set exception

} // end if required

4. You may want to allow for text fields with a value of "Off" and adjust for fields that do not support the "required" property, like the "button" field.

George Kaiser