I'm trying to code a button that will check several mandatory fields and individually highlight them in red if they aren't completed. I do not want to use a submit button.
I can get the code to work for my first field:
if ( form1.pageonesubform.Topchunkpageone.agencyuseonlytable.Row3.typeofrequest.typeofrequestlist.isNull)
form1.pageonesubform.Topchunkpageone.agencyuseonlytable.Row3.typeofrequest.typeofrequestlist.border.fill.color.value = "255,0,0"; xfa.host.messageBox("Some fields are empty. Please scroll up and complete fields highlighted in red.");
form1.pageonesubform.Topchunkpageone.agencyuseonlytable.Row3.typeofrequest.typeofrequestlist.border.fill.color.value = "255,255,255";
But where do I put code for the next if/else? When I set up the exact same code with the next field name under the above if/else code, nothing at all happens -- the first action doesn't even happen. But if I make it "or" with ||, then it will only highlight one field -- the first one.
I need it to do this:
If typeofrequestlist is empty, turn it red, once filled, turn it white
If supvname is empty, turn it red, once filled turn it white
if supvclass is empty, turn it red, once filled turn it white
//and so on
If all fields are filled, show message box "All mandatory fields have been completed."
*** By using the operator || you will only verify the next statements only if the first statement is false...
*** By using the operator | you will verify each statements, even if it's true or false
I wanted to specify this statement about the operators to make sure you don't get mixed up between the two different possibilities...
If you want to have your own validation without having to use a submit button with Adobe Validation, I have custom made a function which validates all visible fields within any PDF. Have a look if this could help you save time and also it is easy to manipulate the validation.
Excellent, thanks both of you for your help.
You have to download the PDF on your PC to be able to open it with LiveCycle Designer... Adobe Reader in a browser will not work with this dynamic PDF.
Magus069, I would love to see your code.
When I click on the Google Drive link, the PDF won't open for me. 😞
In the script editor you can generate the reference to your fields. Place your cursor in the Script Editor where you want your reference to appear, then go back to the form and select the object while holding down the Ctrl key and the reference will inserted into your Script. Because your references are so long it looks like you have typed them in which would make it easy to make a mistake.
If you are still having problems, upload your form somewhere like DropBox or Google Docs, and post a link in this thread and we can have a look.