0

If there is any posibility to add javascript to Sharepoint list edit form? I would like to hide/show field on form if other field has or hasn’t value. I tried use Power Apps but it isn’t working in real time (you have to save element end open it again to see that field was hidden). Have you any idea how to do this?

0

Yes it is possible using Javascript. Please try the below format.
Note: I have tested this in SharePoint 2016 Standard Edition.


$(document).ready(function() {
decideFunc();// to hide or show for new form
//the below code used for on change event of the text. Here am using input type text column as //Base Column.

$('input[id*="BaseOnColumnID"]').on('input',function(e){

decideFunc();
})
});

function decideFunc(){

if($('input[id*="BaseOnColumnID"]').val().trim().toLowerCase()!="value")
{
hideColumn();
}
else
{
showColumn();
}
}//decideFunc ends
function hideColumn(){

$('input[id*="ColumnID"]').closest("tr").hide();

$('input[id*="ColumnID"]').val("");//clear the value while hide

}//hideColumn ends
function showColumn(){

$('input[id*="ColumnID"]').closest("tr").show();

if(!$('input[id*="ColumnID"]' ).val().trim().length){

$('input[id*="ColumnID"]').val("");}
}//showColumn ends

3
  • How you applied this script? Using InfoPath or other solution?
    – Iwoo
    Jun 14 '19 at 7:28
  • Add the "Content Editor Webpart" by editing the list form. We can put the JS URL in that "Content Editor Webpart". Sorry i didn't have the the real-time experience in SharePoint 2019 Online. As per my research knowledge, You should enable the "Classic List Experience" under the "List Settings=> Advanced Settings", to edit the list forms.
    – Xavi
    Jun 14 '19 at 14:38
  • Unfortunetly, I think that there is no option like that with new SP2019 :(
    – Iwoo
    Jun 26 '19 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.