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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Users online (2,715)