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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Hiding fields based on...
Power Pages
Unanswered

Hiding fields based on email value AND boolean yes/no field

(0) ShareShare
ReportReport
Posted on by 35

Hello! 

I have a page on my portal that requires a bit of customization through JavaScript. I would like to hide fields based on an email address entered, which works fine. However, when the user enters the email domain that will show some fields, I would like to apply additional formatting. 

 

$(document).ready(function () {

$("#emailaddress1").change(onShowHideEmployeeFields);

onShowHideEmployeeFields();

});

function onShowHideEmployeeFields() {

var varEmail = $("#emailaddress1").val()

//alert(varEmail)

if (varEmail.includes("@example.org")) {

$('#xxx_employeeid').parent().parent().show();

$('#xxx_employeeid').prop('required', true);

$('#xxx_employeeid').closest(".control").prev().addClass("required");

$('#xxx_defaultfacilityid').parent().parent().show();

$('#xxx_defaultfacilityid').prop('required', true);

$('#xxx_defaultfacilityid').closest(".control").prev().addClass("required");

$('#xxx_positiontitle').parent().parent().show();

$('#xxx_judicialofficer').parent().parent().show();

$('#xxx_judicialofficer').prop('required', true);

$('#xxx_judicialofficer').closest(".control").prev().addClass("required");

$('#xxx_jopositiontitle').parent().parent().show();

}

else {

$('#xxx_employeeid').parent().parent().hide();

$('#xxx_defaultfacilityid').parent().parent().hide();

$('xxx_defaultfacilityid_label').parent().parent().hide();

$('xxx_positiontitle_label').parent().parent().hide();

$('#xxx_positiontitle').parent().parent().hide();

$('#xxx_judicialofficer').parent().parent().hide();

$('#xxx_jopositiontitle').parent().parent().hide();

}

}

function onDisplaySectionChange() {

var varJO= $("#xxx_judicialofficer").find("input[type='radio']:checked").val();

//alert(varJO)

if (varJO === true) {

    $('xxx_jopositiontitle').parent().parent().show();

}

else {

$('xxx_jopositiontitle').parent().parent().hide();

}

}

The first part of my code works fine. However, I'm trying to show the JO Position Title field IF the Judicial Officer Yes/No boolean field is Yes. 

 

Any thoughts on this?

Categories:
  • AK91 Profile Picture
    35 on at

    Bump

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @aakk9911,

    Is this the function you are having issues with ?

     

    function onDisplaySectionChange() {
    
    var varJO= $("#xxx_judicialofficer").find("input[type='radio']:checked").val();
    
    //alert(varJO)
    
    if (varJO === true) {
    
     $('xxx_jopositiontitle').parent().parent().show();
    
     }
    
    else {
    
     $('xxx_jopositiontitle').parent().parent().hide();
    
     }
    
    }

     

    Try replacing it with below codes

     

     $('#xxx_judicialofficer').change(function () {
    
    		var varJO= $("#xxx_judicialofficer").val();
    		
    		//alert(varJO)
    		
    		if (varJO === 1) {
    		
    			$('xxx_jopositiontitle').parent().parent().show();
    		
    		 }
    		
    		else {
    		
    		 $('xxx_jopositiontitle').parent().parent().hide();
    		
    		 }
    		}

     

  • AK91 Profile Picture
    35 on at

    Hi @Anonymous 

     

    Thanks for the reply and suggestion. Unfortunately, the code you provided did not hide the JO Position field when the Judicial Officer? boolean field was marked 'Yes' -

     

    aakk9911_0-1647968048859.png

    I deleted all the other code just to test this one piece for the JO Position Title and the results were the same. Would you happen to have any other suggestions?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 43

#2
sannavajjala87 Profile Picture

sannavajjala87 30 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 20 Super User 2026 Season 2

Last 30 days Overall leaderboard