cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Newmayer2384
Regular Visitor

Set field on form not required based on a chechbox

Hi,

 

I need to set a field (that is normally required) to "not required" if a checkbox gets checked!

 

How would I achieve this with javascript? 

 

 

Thanks in advance!

3 REPLIES 3
ragavanrajan
Super User
Super User

Hi @Newmayer2384 , 

 

 You can inspect the element, get the element's id, and then try the following code as an example. 

 

 $(document).ready(function(){
$("#isCheckBox1").on('change', function() {
  if ($("#isCheckBox1").is(':checked'))
    alert("checked");
  else {
    alert("unchecked");
  }
});

  });

 

Again this is an example. I am not sure what is your full requirement.  Please give a try. 

 

Hope it helps. 

 

Hope it helps. 
------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

Hi, 

thanks for the answer!

 

However I am not sure how to implement the logic to set a field not required.  I need to set a lookup field (parentcustomerid) not required as soon as a checkbox of (xxx_idontfindmyorg) is checked. 

 

Thanks for the help! Much appreciated. 

shil12
New Member

Hi @Newmayer2384 

 

I hope the following links will answer your questions.

Get-and-set-field-values-using-formcontext-and-javascript-with-dynamics-365

How-to-set-field-requirement-as-mandatory-required-using-javascript-and-how-to-register-function-in-... 

If you are looking for the best developers course to learn how to write JavaScript Microsoft Dynamics 365 training online, I would suggest you check out 

Microsoft Dynamics 365 Developers-technical-training-part-2 

 

Thanks

shilpa

Web: https://www.dynamicslabs.io/

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel News & Announcements 768460.png

What's New in the Community?

Check out the latest News & Events in the community!

MPP IDEAS updated 768x460.png

Ideas

Discover ideas and concepts from users like you for how to use Power Pages and take your work to the next level.

Top Solution Authors
Users online (3,624)