Expand my Community achievements bar.

Attention: Experience League Community will undergo scheduled maintenance on Tuesday, August 20th between 10-11 PM PDT. During this time, the Community and its content will not be accessible. We apologize for any inconvenience this may cause.

Validate Fields-Scope Issue

Avatar

Former Community Member
I have a 7 page PDF form that requires field validation. When a user clicks the print button, I need to pop-up appropriate error messages. However, my print button is on page 7 and it cannot see my text field(s) on page 1 of my form, a scope issue. Because when I place my print button on page 1, it sees my form field.



Is there a way to make these fields global in scope where the print button can see it on an onclick event?
20 Replies

Avatar

Former Community Member
You can see all the fields on the form, you just need to fully qualify the SOM instead of using a relative SOM expression. If you just use the name (ie: someField) it from within the scope of the button it will look for a someField underneath the parent of the button. In your case you would do something along the lines of:



xfa.formName.page1Name.fieldName



As a worst case you could always use the resolveNode() method to get a reference to the field.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Ok, couple questions:



1) how do you give your form a name in Adobe Designer?

2) the individual pages have a name? Or can you use page1?



Thank you for the response.

Avatar

Former Community Member
You can rename them from the hierarchy tab. By default your form object will have a name (form1 usually) and the page subforms will be untitled (you should name them). To change the name, select the node in the hierarchy tab and hit F2, or right click and choose Rename Object.



If you don't give your pages names you can still access them using resolveNode(). Something like this would be the 2nd page:



xfa.form.formName.resolveNode("#subform[1]");



But it's much simpler to name them in most cases.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Ok, thank you again. The field is now validating properly with:



application.page1.lastname.rawValue==null



Another question, originally I had this to set focus in another PDF form I was doing:



xfa.host.setFocus("nameoffield")



However, with this new form, I can't find a set focus attribute. I've tried this:



application.page1.setFocus("nameoffield")



And nothing. Do you reference it elsewhere?

Avatar

Former Community Member
What do you mean you can't find it? You would still do xfa.host.setFocus(somExpressionToField).



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Using the above code does not bump me to the selected field in PDF preview mode.



Not to deter from the question at hand, but how do you check the status of a radio button or checkbox selection? Sorry for the amount of questions, just not much documentation on my end.

Avatar

Former Community Member
Depending on the hierarchy of the form and where you run the setFocus() script from you may need to use a full SOM expression instead of just the field name.



You check the status of a radio button by checking the rawValue of the exclusion group, and the for a check box by checking it's rawValue. The actual value you get back depend on options you assigned when creating the field.



Chris

Adobe Enteprise Developer Support

Avatar

Former Community Member
Hmmm...the name of my form is application, page1 is the first field, and field name is positionapplied. I tried this combination:



xfa.host.application.page1.setFocus("positionapplied");



Nothing.



I've omitted xfa.host and nothing. Is there something I'm missing in the path? Thank you for the radio and check box help, makes sense.

Avatar

Former Community Member
Try



xfa.host.setFocus("application.page1.positionapplied");



setFocus() is a method of the host object, and you pass the SOM expression for the field into it.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Cool, that works. Care if I ask a few more questions?



What is the host object? Is that the name of the form internally to Adobe Designer?



What does SOM stand for? Are the expressions sort of like how you define or set paths in html web pages?

Avatar

Former Community Member
If you don't already have the XML Forms Object Model Reference you should get it here: http://partners.adobe.com/public/developer/livecycle/designer/devcenter.html



Here's an excerpt for the host object:



The XML Form Host Model provides a set of properties and methods for working at the application level. These properties and methods are available for scripting regardless of the hosting application.



So basically it provides methods and properties that work at the application level whether your rendering as PDF or HTML.



So, in the process of trying to figure out what the S in SOM stood for, I found this great document that Adobe has put out on the web :P http://partners.adobe.com/public/developer/en/xml/som_2.0.pdf



It stands for Scripting Object Model. Basically it's used to path to specific nodes in an XML DOM. But for more info take a look at that document :D



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Great, I will definately read up on these documents!



Thanks.

Avatar

Former Community Member
Hi Chris,



I do have this form that I am working on and have almost done, but I'm having problem with validating the zip code and the telephone number. In the zip code if the user enters less or more than five digits it should prompt them to enter 5 digits. In the telephone number, if the user enters anything that does not follow the format of 999-999-9999, it should prompt the user to enters that. I've been having problem getting my form which I'm designing using Adobe livecyle to do the above.



Please, can you help me out with your expertise.



Thanks



Lucky Pianwi

Avatar

Former Community Member
Hi All,



I have earlier sent in this particular problem without any response, hence, I am addressing it to all the user on this forum for solutions. I do have this form that I am working on and have almost done, but I'm having problem with validating the zip code and the telephone number. In the zip code if the user enters less or more than five digits it should prompt them to enter 5 digits. In the telephone number, if the user enters anything that does not follow the format of 999-999-9999, it should prompt the user to enters that. I've been having problem getting my form which I'm designing using Adobe livecyle to do the above.



Thirdly, I do have a field"Firstname", which on exit comes up with a response requesting the user if it's a "BA" management issue? If the user selects yes or ok it should move the focus to field"BE" else "field"BF". This is the code I have for it and is on the exit event, but do not work.



var a = xfa.host.response("Is it a BA management issue", "2. BA management";



if (a == NULL){

xfa.host.setfocus"BE";

else{

xfa.host.setfocus"BF";

}



}

Please, can you help me out.



Thanks



Lucky Pianwi

Avatar

Former Community Member
For the zip code you'd use a validation pattern of 99999.



For the telephone number, there is already a custom field defined under the custom tab that has the validations set up for this.



For the message, I'd do something like this:



var answer = xfa.host.messageBox("Is it a BA management issue?", "2. BA management", 2, 2);



if (answer = 4) { //yes

xfa.host.setFocus("BE");

} else { //no

xfa.host.setFocus("BF");

}



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Hi Chris Trubiani,



Thanks so much for your help. However, I am still having problem with the Zip Code because the vaidation error message only works when user inputs more than 5 digits. If a user enters less than 5 digits, the validation error message does not work.



Secondly, I will like to find out if there are defined values for, "Yes", "No", "Ok", and "Cancel" just like we have in vbscript.



I greatly appreciate this help.



Thanks



Lucky Pianwi

Avatar

Former Community Member
Use this link...I had same problems with SSN..you can modify the code for Zip




Marleen L, "Where to put the validation code?" #, 17 Mar 2006 5:43 am



you would need to make changes in script rather than in the object palette

Avatar

Former Community Member
Are you using a Numeric Field or Text Field? If Numeric then you should be using a Text Field.



What do you mean by defined values for, "Yes", "No", "Ok", and "Cancel"? I'm not familiar with vbscript so not sure what's it's like.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
i found a super cool secret code to validate the whole form in one line of code!



F.execValidate();



so my print button is a normal button (not a print button)

with this code for onclick:



if(F.execValidate())

{

xfa.host.print(1, "0", (xfa.host.numPages - 1).toString(), 0, 1, 0, 0, 0);

}



easy as that!

IMPORTANT:

- unfortunatly it does not check if required fields are empty

- it only checks the "validation pattern" under Object > Value

- the "Error" box beside "validation pattern message" MUST be checked (if it is not checked, your validation errors will still popup, but the function will return true when it should be false - and therefore the print box will popup)

Avatar

Former Community Member
im having the similar problem. Im trying to create a field that users can only enter number. If they enter text, an error message should pop up. I can't seem to get it to work although i got the error message to show when users enter text. However, im not sure what i need to put in the "validation pattern" box. Should it be 9 or 99999 or 999999999. None of those worked, as i have tried. If someone has any idea. Please help. Thanks.