Expand my Community achievements bar.

SOLVED

Field highlighting for validation

Avatar

Level 2

Hi,

Is there a way that the fields can be highlighted using the required field validation without clicking the Submit button. I have something like a validate button which is a regular button, but that doesn't seem the work with the same code in it. The Submit button highlights the madatory fields and pops-up an error message. My requirement needs both the buttons to be repsent on the form. Please help.

Regards,

NG

1 Accepted Solution

Avatar

Correct answer by
Level 10

It took some time to figure it out..

We are trying to set the color and thickness but the edge presence was hidden. You need to make the edge visible..

Use the below code to make it work for you..

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.presence = "visible";

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.color.value = "252,28,3";

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.thickness = "2.5pt";

Note: You have already made the field as User Entered -Required. Then the Reader/ Acrobat will place a Red Border around the field by default for all mandatory fields. Also you have a function at the time of initialize to make the field as mandatory.

If you want to test the above code, you need to comment out the initialize event code to call the Validate function, and change the field to User Entered - Optional.

Thanks

Srini

View solution in original post

8 Replies

Avatar

Level 10

You can try using the Validate event of the fields that you want to be mandatory. If the validation fails, then you can highlight the field.

For highlighting you can use some thing like this.

var strFieldName = this.somExpression;
var strField = xfa.resolveNode(strFieldName + ".ui.#textEdit.border.fill.color");

strField.value = "255,255,255"; // RGB color Value that will highlight the field.

You need to change the ui reference based on the type of control you are using.

    Date field = #dateTimeEdit 
    Dropdown = #choiceList 
    Checkbox = #checkButton 
    Text field = #textEdit 
    Numeric field = #numericEdit

Thanks

Srini

Avatar

Level 2

Thanks for the prompt response Srini.

I tried this out, however, I filles the entire field with the specified color. I just need to color the edges of the field. I tried using

..textEdit.border.edge.color.., but thus colors only the one border, the top one. I even tried ..textEdit.border.edge[2].color.., but this didn't color any of the edges. The appearance of my field is solid as per the requirement.

Avatar

Level 10

If you just want to highlight the border try using this.. Where fieldname is TextField1. Change it to your field name..

TextField1.border.edge.color.value = "207,29,3";

If it is only hightlighting one side of the border, did you place this control inside a table row?

If it is in Table row, the color of field borders can conflict with the borders of the Row and Table, the next cell, the previous cell, the cell above, the cell below etc..

Thanks

Srini

Avatar

Level 2

this too ins't helping. Itsnot chaning the color for any of the edges.

Avatar

Level 10

Can you send your form to LiveCycle9@gmail.com so I can have a look at it..

Thanks

Srini

Avatar

Level 2

I have sent you the form. Plz let me know if you have any queries in that.

Avatar

Correct answer by
Level 10

It took some time to figure it out..

We are trying to set the color and thickness but the edge presence was hidden. You need to make the edge visible..

Use the below code to make it work for you..

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.presence = "visible";

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.color.value = "252,28,3";

EFormsData.Page1.pageSelection.formsIntro.coverDetails.busNam.border.edge.thickness = "2.5pt";

Note: You have already made the field as User Entered -Required. Then the Reader/ Acrobat will place a Red Border around the field by default for all mandatory fields. Also you have a function at the time of initialize to make the field as mandatory.

If you want to test the above code, you need to comment out the initialize event code to call the Validate function, and change the field to User Entered - Optional.

Thanks

Srini

Avatar

Level 2

Thats perfect!!!!!!!

It worked. Thanks a lot for helping me resolve this within a day.