Hi,
I'm guessing there's a way to programmatically check if any field has been entered when the form loads. Some sort of loop should do the trick...
I've tried using the following code (from dohanlon for another purpose) which should run through all form fields, but I can't seem to plug it into an if/else statement or even check for any non-null value.
xfa.resolveNodes("form1..#field[*]");
Here's conceptually how I'd like to do it:
if (xfa.resolveNodes("form1..#field[*\]".rawValue != null ) {
do it
}
I'm basically trying to check if any field is not null, then I can "do something". I know I can't use that to check .rawValue but I can't think of anything else.
I would appreciate any help (as always).
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I prefer loops, as you can build in a bit of error handling as well.
See an example here: http://assure.ly/H1ksGR.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
I prefer loops, as you can build in a bit of error handling as well.
See an example here: http://assure.ly/H1ksGR.
Hope that helps,
Niall
Views
Replies
Total Likes
resolveNodes method will only return a list of objects which you need to loop through.
Views
Replies
Total Likes
Hi David,
Niall is probably right about a loop giving you more control, but you could try;
if (xfa.resolveNodes('form1..#field.[ui.oneOfChild.className <> "button" and not HasValue($)]').length > 0)
{
// do something
}
(butttons always return seem to return a null value)
Just another way to try.
Bruce
Views
Replies
Total Likes
Hi,
Call the below method on click of a button it will check all the fields and subform fields recursively.
Note:Make necessary changes as per comment.
function nullCheckAllFields(myParentObject){
var allChildElements;
var intNumElements;
var currentElement;
var j;
//Get all the child nodes of the parent element
allChildElements = myParentObject.nodes;
//Total number of element in the object
intNumElements = allChildElements.length;
//Loop through all the child elements
for(j=0; j< intNumElements;j++){
currentElement = allChildElements.item(j);
//If the element is another subform we'll recusively call the function again
if(allChildElements.item(j).className == "subform"){
nullCheckAllFields(currentElement);
}
//If the objects are fields or exclusive groups then we'll check them, null or not
else if(currentElement.className == "field" || currentElement.className == "exclGroup")
{
if(currentElement.rawValue==null)//Exclude the fields for that you don't want to check like button etc.
{
//do whatever you want to do
// break;//use break if want to check one at a time
}
}
}
}//end function
Thanks
Niall, that form you linked to is great ( http://www.assuredynamics.com/wp-content/uploads/2012/03/Assure-Dynamics-Form-validation-Acrobat-ver... ).
But there is something you did that I cannot replicate. You set the contact fields (except "address") as required, yet they do not show up with red borders when the form initializes. Furthermore, the Adobe Reader banner which allows the user to "highlight fields" does not show up.
I assume youe script in the Function removes the red borders
currentElement.nodes.remove(currentElement.border);
As long as it doesn't fail the test. If that's the case, then that shouldn't be a big deal. But I have no idea how you removed the banner...
Views
Replies
Total Likes
Hi,
I have specifically turned off the field highlighting, as I don't want this on. It would contradict the scripted highlighting of mandatory fields that have failed. See the script in the docReady event of the root node (form1):
// Turn off the highlight colour for fields
app.runtimeHighlight = false;
The above script turns off the highlighting, but I find that the Document Message Bar (purple banner) tends to show/not show depending on the type of PDF opened. Because I don't have a "real" submit button, the purple banner isn't visible. If you did have a Submit button the purple banner would be present, however the above script would still turn off the actual highlighting. Make sense?
Because I am specifically/only applying a red border to fields that fail validation (using script), then yes the script you copied is removing the red border if the field subsequently passes validation.
When I developed this example initially, you will see that in the exit event of the root node I am calling the onExit function to clear the red border if it passes validation. The intention was that this event was propagated, so that it would be called when the user exits every field. However propagation is not supported in Acrobat/Reader version 8.1.
Hope that helps,
Niall
Thanks for following up.
RE the banner,
My form (and also the dummy I'm experimenting with) does not have a real submit button either. Yet the purple banner is showing. When I preview your PDF in LiveCycle, it shows the purple banner for a split second, and then it disappears. Are you sure that you did not programmatically remove it somehow?
Views
Replies
Total Likes
Hi David,
I am fairly sure I havent. For example, if you drg on a Submit by Email button, I am sure the Document Message Bar will be visible.
Give it a try,
Niall
Views
Replies
Total Likes
Hi,
This is very strange.
1. When I do drag a submit button onto your form, the banner does pop up (and disappears after I delete it).
2. Yet in my dummy form (which only has 3 decimal fields and an OK button), the banner shows up always.
Perhaps this has something to do with the version of LiveCycle it was created in? When you create a new form, the purple banner never shows unless you place a submit button then?
Views
Replies
Total Likes
Hi,
The behaviour is more determined by Acrobat/Reader than LC Designer. The Document Message Bar changes depending on what is happening in the PDF. For example if the JavaScript trust is triggered, then the Document Message Bar is yellow.
See a discussion here: http://forums.adobe.com/message/3796028#3796028.
I would get too worries about it. My general preference is to have the Document Message Bar hidden. But in the example form I don't think I have scripted for this, other than turning off the highlighting.
Niall
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies