web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Need to make a fields "required" setting conditional on a marketing form

(0) ShareShare
ReportReport
Posted on by 36
Hello, I need assistance coding a field to make its /required/ setting conditional. 
 
I have not yet added the field to the form, but it will be a field called /company name/ and i want it to be visible all the time (which i can do), but required ONLY in the event that the event type = school & university OR corporate. 
 
Can someone please help me with this?
 
I have the same question (0)
  • Suggested answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    It is possible to implement this functionality by inserting JavaScript into the Outbond marketing form.
        let EventType = document.getElementById("49ce3bed-4a59-ee11-be6f-002248213b02");
        let companyName = document.getElementById("81020a1e-4b59-ee11-be6f-002248213b02");
        let star = document.createElement('span');
        star.innerText="*";
        star.style.color = 'red';
        let label = document.getElementById("companyName");
        let index = EventType.selectedIndex;
        EventType.addEventListener("change",function(e){
            e.stopPropagation();
            let index = EventType.selectedIndex;
            companyName.removeAttribute('required');
            if(label.children.length !==0){
                label.removeChild(star);
            }
            if(EventType.options[index].innerText === "Corporate Event" || EventType.options[index].innerText === "School&University Events"){
            companyName.setAttribute('required',true);
            label.appendChild(star);
            }
        })
     
    1. The string in parentheses in this line of code comes from the id value of the /select/ label for the 'What Type of Event do you want to host?' field.
     
    2. The string in parentheses in this line of code comes from the id value of the /input/ label for the 'Company Name' field.
     
    3. The string in parentheses in this line of code comes from the id value of the /label/ label for the 'Company Name' field.
    This id value does not exist by default and needs to be added manually.
     
    4. The final result is shown below.
     
    I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Dengliang Li
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 130 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 117

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans