Mr.P
Mr.P

Reputation: 5

How do I make Apex text field required value dynamically

I have JS line

document.getElementById(element).required=true;

How do I make it work in Oracle APEX?

I have a form with select list that has values Yes/No. If a value is "Yes", 2 more text fields appear. I have done it by making dynamic action (when item is changed and gets specific value) but there was no option to set required values, so I tried to "Execute JS code".

But JS line above didn't work.

Upvotes: 0

Views: 10267

Answers (2)

Ftaveras
Ftaveras

Reputation: 719

You must add two conditionals validations for those text fields.

  1. Set field template as required, but leave it "Is Required" as "No". enter image description here
  2. Add a validation for each field and make it "Conditional" setting it condition type to "Value of Item / Column in Expression 1 = Expression 2". On "Expression 1" set your select Name and "Expression 2" to desired value. Add Condition enter image description here Validation Level enter image description here Validation Type enter image description here Condition enter image description here

Upvotes: 3

Bart van der Drift
Bart van der Drift

Reputation: 1336

When you make an item required it is always required when you submit the form. You'll have to resort to page validations to check if it has a value in specific cases.

Upvotes: -1

Related Questions