Expand my Community achievements bar.

Urgent: Checking All the Numeric fields in a form

Avatar

Former Community Member
Hi All,



I have a form which has a lot of numeric fields. The fields accept integer values only. I need to make sure that no field contains a negative integer.



I have the following script which is failing at the point app.alert("Called"); i.e. the innermost if. Please Help. I have a deadline and I am stuck at this last thing.



function testAll()

{



for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

{

var oFields = xfa.layout.pageContent(nPageCount, "field");

var nNodesLength = oFields.length;



var sProperty = "rawValue";

var sFillColor = "fillColor";

var sFillColorRed = "255,0,0";

var sFillColorWhite = "255,255,255";

var sValue = "0";



for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

{



if (oFields.item(nNodeCount).ui.oneOfChild.className == "numericEdit") // if it is a numeric field

{

if ((oFields.item(nNodeCount).ui.oneOfChild)[sFillColor] == sFillColorRed )) // value is less than 0

{

app.alert("Called");



//(oFields.item(nNodeCount).ui.oneOfChild)[sFillColor] = sFillColorRed;

}

}

}



}

} // end function
1 Reply

Avatar

Former Community Member
I got it working. Here's the code



// Check all the numeric fields in the document



function testAll()



{



var functionReturn = false;







for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) // check all the pages in the document



{



var oFields = xfa.layout.pageContent(nPageCount, "field");



var nNodesLength = oFields.length;







var sRawValue = "rawValue";



var sFillColor = "fillColor";



var sFillColorRed = "255,0,0";



var sFillColorWhite = "255,255,255";



var sValue = 0;



var sAccess = "access";



var sReadOnly = "readOnly";







for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) // check all the nodes in each page



{







if (oFields.item(nNodeCount).ui.oneOfChild.className == "numericEdit") // if it is a numeric field



{



if (oFields.item(nNodeCount)[sRawValue] < sValue && oFields.item(nNodeCount)[sAccess] != sReadOnly) // value is less than 0 and it is not a Readonly field



{



functionReturn = true;



oFields.item(nNodeCount)[sFillColor] = sFillColorRed;



}



if (oFields.item(nNodeCount)[sRawValue] >= sValue && oFields.item(nNodeCount)[sAccess] != sReadOnly)



{



oFields.item(nNodeCount)[sFillColor] = sFillColorWhite;



}



}



}







}



return functionReturn;







} // end function