That is helpful, but I still have some questions.
I've created a form with required text fields. These fields are set to be highlighted if the user tries to print the form with nothing in those fields.
There are 2 required dropdown lists in the form, as well. I need to have them validate with the other fields in the click event (script below) or not allow the user to exit the field until a valid option is selected. I had tried the following script (from an earlier message in this topic) in the field's exit event, and got close to what I need:
if(fdType.rawValue == null) {
xfa.host.setFocus("xfa.form.form1.fdType");
}
Maybe the above script should be linked to a different event? To add to the issue, I have fields highlighted on enter and the highlight disappearing on exit. The script above worked except for allowing an invalid option being selected (which the attachment would correct) and leaving the field highlighted even after it was exited.
I guess what I need is a way to combine the several parts into a working whole. Any help is greatly appreciated!!
click script:
var iVar=0;
if ((fdName.rawValue==null) || (fdName.rawValue=="")) {
app.alert("Please enter the fund name.");
// Change color of fillable area of text field.
xfa.resolveNode("fdName.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("fdName.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("fdName.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("fdName.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((donorInfo.rawValue==null) || (donorInfo.rawValue=="")) {
app.alert("Please enter donor restrictions/instructions.");
// Change color of fillable area of text field.
xfa.resolveNode("donorInfo.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("donorInfo.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("donorInfo.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("donorInfo.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((dept.rawValue==null) || (dept.rawValue=="")) {
app.alert("Please enter the department.");
// Change color of fillable area of text field.
xfa.resolveNode("dept.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("dept.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("dept.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("dept.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((fdAdmin.rawValue==null) || (fdAdmin.rawValue=="")) {
app.alert("Please enter the fund administrator.");
// Change color of fillable area of text field.
xfa.resolveNode("fdAdmin.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("fdAdmin.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("fdAdmin.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("fdAdmin.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((subName.rawValue==null) || (subName.rawValue=="")) {
app.alert("Please enter your name.");
// Change color of fillable area of text field.
xfa.resolveNode("subName.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("subName.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("subName.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("subName.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((subTitle.rawValue==null) || (subTitle.rawValue=="")) {
app.alert("Please enter your title.");
// Change color of fillable area of text field.
xfa.resolveNode("subTitle.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("subTitle.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("subTitle.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("subTitle.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((subEmail.rawValue==null) || (subEmail.rawValue=="")) {
app.alert("Please enter your email address.");
// Change color of fillable area of text field.
xfa.resolveNode("subEmail.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("subEmail.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("subEmail.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("subEmail.ui.#textEdit.border.fill.color").value="255,255,255";
}
if ((subTel.rawValue==null) || (subTel.rawValue=="")) {
app.alert("Please enter your phone number/extension.");
// Change color of fillable area of text field.
xfa.resolveNode("subTel.ui.#textEdit.border.edge").stroke="solid";
xfa.resolveNode("subTel.ui.#textEdit.border.fill.color").value="255,0,0";
// Set variable to indicate that field does not contain data.
iVar=1;
}
else {
// Reset fillable area of text field.
xfa.resolveNode("subTel.ui.#textEdit.border.edge").stroke="lowered";
xfa.resolveNode("subTel.ui.#textEdit.border.fill.color").value="255,255,255";
}
// If all required fields contain data, iVar is set to zero and form prints.
if (iVar==0) {
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);
}