Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
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?

  • AK91 Profile Picture
    35 on at
    Re: Hiding fields based on email value AND boolean yes/no field

    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?

  • Community Power Platform Member Profile Picture
    on at
    Re: Hiding fields based on email value AND boolean yes/no field

    @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
    Re: Hiding fields based on email value AND boolean yes/no field

    Bump

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35