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 :
Microsoft Dynamics CRM (Archived)

Making field required on web page form based on user input value for other input field ?

(0) ShareShare
ReportReport
Posted on by 342

When say x or y values are opted on A lookup field on the web page form than B field should be required. How can we achieve this using ASP code

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Hello sandy,

    You can use business rule for making field required on your condition.

    Please check below link for creating business rule

    www.powerobjects.com/.../become-pseudo-developer-business-rules-crm-2013

    Best Regards,

    Shahbaaz

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Sandy,

    Are you looking for suggestion on Dynamics 365/CRM or asp.net? If DYnamics 365/CRM then use business rules.

    Refer this.

    www.crmsoftwareblog.com/.../microsoft-dynamics-crm-business-rules-needs-required-fields

    Hope this helps.

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    if you are trying to do this by ASP code then i don't think this is possible, instead you can write java script code.

  • Sandy Hello Profile Picture
    342 on at

    looking for ASP.net

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    i think you posted the same question yesterday also right? can you brief about your requirement so we can provide you solution.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Sandy,

    Sorry but this forum if for DYnamics 365/CRM. You can post your questions on ASP.Net forum to get the relevant suggestions-

    https://forums.asp.net/

    www.c-sharpcorner.com/forums

    Hope this helps.

  • Sandy Hello Profile Picture
    342 on at

    I apologize i have confused with requirements my requirement is to make field mandatory on web form hosted on server when other input field value is selected. It it can be done with javascript please help me out.

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Please check below code

    // keep this funciton on lookup on change event

    function onchangeeventoflookup() {

    //get the lookup value name
    var lookup = Xrm.Page.getAttribute.("schemanameoffield").getValue();
    if(lookup != null && lookup[0] != null)
    {
    var name = Xrm.Page.getAttribute.("schemanameoffield").getValue()[0].name;

    if(name=="test")
    {

    Xrm.Page.getAttribute("schemanameoffield").setRequiredLevel("required");

    }

    else

    {

    Xrm.Page.getAttribute("schemanameoffield").setRequiredLevel("none");

    }
    }


    }

    Make sure you provide proper schema name of lookup field as well as schema name of field that you want to make mandatory.

    If you find it helpful, please mark my answer as verified.

    Thanks,

    Shahbaaz

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 > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans