Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to make a field required

Avatar

Level 4

I'm using Adobe LiveCycle 8.0. I just created my first form. There is a few fields I would like to make required. I already have the TAB order the way I need it to be. Here's what I need to happen: If a user starts filling out the form & does not fill in any information in the client ID field, & they hit the TAb key, I want some kind of error to pop up telling them the client ID field is required. Is this possible? Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

As Dallas Kuhn said:

if (this.rawValue == '' || this.rawValue == null){

xfa.host.messageBox("The client ID field is required.");

}

The script should be added on the Exit event for the client ID field.

Can you post the form and I'll have a look at it?

View solution in original post

0 Replies

Avatar

Level 4

You can put the following JavaScript code into the exit event of the Client ID field:

if (this.rawValue == '' || this.rawValue == null){

xfa.host.messageBox("The client ID field is required.");

}

Just make sure you have selected JavaScript from the Language drop down and not FormCalc. You can also set the field type as 'User Entered - Required' in the 'Value' tab of the 'Object' Palette and insert a message in the 'Empty Message' box. This will then validate on submitting the form and a red border will appear on that field.

Avatar

Level 2

In JavaScrpt you can use the following:

this.mandatory = "error"

It should be noted that it is not possible to turn of mandatory fully when in a formguide (if you are planning on using one.)  It leaves an asterisks character in the caption.

Avatar

Level 4

I have the form set to use JavaScript not FormCalc but I can't find the place I need to be to add the JavaScript....I've looked everywhere in the properties..can you advise me where to add the code?

Avatar

Level 4

Under the hierarchy tab I thought I could right click the field & choose "Insert Script Object" but "Insert Script Object" is greyed out.

Avatar

Correct answer by
Level 2

As Dallas Kuhn said:

if (this.rawValue == '' || this.rawValue == null){

xfa.host.messageBox("The client ID field is required.");

}

The script should be added on the Exit event for the client ID field.

Can you post the form and I'll have a look at it?

Avatar

Level 4

I think your Script Editor is minimized. You can view it by clicking and dragging down the little arrow above the 'Preview PDF' tab, or select Window > Script Editor (Ctrl+Shift+F5). Once that is visible you need to click on the required field and then choose 'exit' from the 'Show' dropdown on the top left hand side of the editor. Paste that code in there.

Avatar

Level 10

Script objects are for reusable functions, not for simple scripts attached to fields.

Ctrl-Shift-F5 will open the script editor for you if it's closed. Once in the script editor you can select the event that you want to attach the script to.

Avatar

Level 2

I would like to eliminate that obnoxious red border while still making certain fields mandatory before using a submit button. Possible?