Highlighted

Turn caption text red when required field is empty

Avatar

Guest

06-11-2008

I am creating a form for a client that has a number of "required" fields. I created my own button and have added script that will pop up a messageBox and change the fill color of the text field (see sample code below). The customer would prefer to have the caption label change instead and have the text box remain the same. I have tried several things and can't get it to work.



Here is a portion of the script I am using to change the fill color of the textField:



var iVar = 0;

if ((TextField1.rawValue == null) || (TextField1.rawValue == "")) {

xfa.host.meassageBox ("Please enter your Legal Name.");



xfa.resolveNode("TextField1.ui.#textEdit.border.edge").stroke = "solid"

xfa.resolveNode("TextField1.ui#textEdit.border.fill.color").value = "255,100,50";



iVar = 1;



Anyway, I am not sure how to take that concept and apply it to the Caption Label. Please help.



Brian

Replies

Highlighted

Avatar

Guest

07-11-2008

thanks for the reply. I tried:



xfa.resolveNode("TextField1").caption.font.fill.color.value = "255, 100, 50"



but it still does not change the font color.



is my syntax bad, or is there something else I am missing?



thank you for your help
Highlighted

pguerett

07-11-2008

Is you field called TextField1? You do not need an xfa.reolveNode if you reference the field directly. You can reference it by payhing from the root of the form through each subform until you hit the field that you want. Typically form1.Page1.TextField1.....
Highlighted

Avatar

Guest

07-11-2008

I have tried the string without the xfa.resolveNode but still no success. I have tried a number of other variations but it does not seem to work. I wonder if there is something in the surrounding script that is causing the problem. Below is the entire script (with the field color change that works):



form1.#subform[0].Button1::click - (JavaScript, client)



var iVar = 0;

var oDoc = event.target



//Legal Name Field.



if ((TextField1.rawValue == null) || (TextField1.rawValue == "")) {

xfa.host.messageBox("Please enter your Legal Name.", "Form Not Complete", 2,0);



xfa.resolveNode("TextField1.ui.#textEdit.border.edge").stroke = "solid";

xfa.resolveNode("TextField1.ui.#textEdit.border.fill.color").value = "255,100,50";



// Set the variable to indicate that this field does not contain data.



iVar = 1;

}



else {



// Reset the fillable area of the text field.

xfa.resolveNode("TextField1.ui.#textEdit.border.edge").stroke = "lowered";

xfa.resolveNode("TextField1.ui.#textEdit.border.fill.color").value = "255,255,255";

}



if (iVar == 0) {

xfa.host.messageBox("Thank you for completing the Questionnaire.", "Form Completed", 3, 0);

}



do you see anything that i am missing?



thanks
Highlighted

pguerett

10-11-2008

Everything looks good to me ....if you are using Acrobat, Run the script then hit Ctrl-J. The javascript console will come up and if there are any script errors they will appear in that console.



If you still can't find anything wrong, email the form and a brief description of the issue and how to make it happen and I will have a look. Send it to: livecycle8@gmail.com
Highlighted

Luigi_247_365

11-11-2008

Brian... try direct referencing (its long and extended, but works)



here is one example:



xfa.form.LeaveApplication.sfLeaveForm.sfFlowedSection.sfLeaveDetails.specialLeaveType.caption.font.fill.color.value = "255, 100, 50";
Highlighted

Avatar

Guest

12-11-2008

I have tried the direct referencing among other things. I just realized that the script is working, but it is changing the text inside the text box. how do i change the label for the text box (which i thought was the caption)?
Highlighted

Avatar

Guest

13-11-2008

I appreciate all of the help up to this point, Paul and Luigi. to restate the remaining issue, I am able to reference the caption object (as in "textField1.caption.font.fill.color.value = '255,100,50'" and it turns out it is changing the font color for any text that the user enters into the field. The problem is that I would like to change the color of the caption for that field.



For instance, I have a field that appears on the form as "Name:" followed by the empty text field. when the script runs, I would like the word "Name" to change to red if the field is still empty.



is there a different object that i should be using (other than "caption")?



Thank you again for all of your help.



Brian
Highlighted