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
BedrockMission!

Learn More

View all

Sign in to view all badges

Dynamically make object/field required if another field is !=NULL

Avatar

Avatar
Validate 10
Level 2
ndjustin20
Level 2

Like

1 like

Total Posts

60 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
ndjustin20
Level 2

Like

1 like

Total Posts

60 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
ndjustin20
Level 2

01-02-2010

  I am uploading the form I am working with and a screen shot of what I am trying to do.  I've figured out that "<validate nullTest="error"/>" is added to an object when i change it to "user required" within the properties on the side of the livecycle wysiwyg environment.  I really like how adobe handles the required error and stops all other processes while also outlining the menacing field in red.

What I need to do is store the null test but I'm not sure how I can drop this information into the xml.  I tried using document.write but that didn't work so I'm not sure what I am doing wrong.

<script contentType="application/x-javascript">

if (RadioLocation.rawValue == "1")

{

var required = "<validate nullTest="error"/>";

document.write(required);


}//end if

</script>

I need something like this I think but am not too sure how to get this to work exactly.  I though I could put this inside the object I wanted to become required dynamically if RadioLocation.rawValue == "1" but it didn't work so I'm not sure what I am doing wrong.  I'm pretty certain it has something to do with the syntax but have no idea what i could do differently in this case as I am brand new to livecycle code.

Justin

View Entire Topic

Avatar

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Steve_L_Walker
Level 9

01-02-2010

Justin,

There are several ways to approach this. In my example I added the following JavaScript on the change event of the RadioLocation radio button exclusion group. If the user selects 'No' (rawValue '2') I reset the drop-down list, in the event it contains a value, and I disable access to the drop down. If the user selects 'Yes' (rawValue '1'), I make the drop-down available (or "User Entered - Optional").

// form1.#subform[0].RadioLocation::change - (JavaScript, client)

if (RadioLocation.rawValue == "2") {

     DropDownList2.rawValue = null;

     DropDownList2.access = "protected";

}

else {

     if (RadioLocation.rawValue == "1") {

          DropDownList2.access = "";

     }

}

On the drop-down list I add a script to check if the selection is null. If it is null and RadioLocation is 'Yes' (rawValue '1'), I put up a message box,

// form1.#subform[0].DropDownList2::exit - (JavaScript, client)

if (DropDownList2.isNull && RadioLocation.rawValue == "1") {

     xfa.host.messageBox("If 'Other Locations' is 'Yes', please select the # of locations.");

}

Note. I you want to enforce the validation before printing or submitting you will need additional script against the applicable events.
Steve