none
Making Project ID Field Read Only without Workflow RRS feed

  • Question

  • Hi,

    I am trying to make the Project ID field read only on a PDP. We want to display it, but stop users editing it. We are trying to not use workflow, and look at something like JavaScript.

    Looking online, I found some code like this;

     <script src="http://code.jquery.com/jquery-latest.js"
    type="text/javascript"></script>
    <script>
    //this function will wait for the DOM to be ready then execute
    $(document).ready(function(){
    //then we will look for the input that has the title Project ID
     using this input selector
    $('input[title="Project ID"]').each(function(){
    if($(this).val() !="")
    {
    //if the input has a value we will alert a message and make it read only
    alert("Custom field is locked.");
    $(this).attr("disabled", true);
    }

    });
    });
    </script>

    However it doesn't make the field read only (with or without a project id entered

    Can anybody help?

    Thursday, June 13, 2019 12:47 PM

Answers

  • Hi,

    I just used your code. I had to remove a line break and correct http(s!). Just use debugger, to see if any error stops your code from working.

    This is what I used:

    <script src="https://code.jquery.com/jquery-latest.js" type="text/javascript"></script><script>
     //this function will wait for the DOM to be ready then execute 
     $(document).ready(function(){
    
    //then we will look for the input that has the title Project ID  using this input selector
     $('input[title="Project ID"]').each(function(){
     if($(this).val() !="")
     {
    
    //if the input has a value we will alert a message and make it read only
    
    alert("Custom field is locked.");
     $(this).attr("disabled", true);
     }
    
    
    });
     });
     </script> 

    Regards
    Barbara


    Barbara Henhapl Blog (English/German) MVP

    • Marked as answer by Jumpy99 Friday, June 14, 2019 1:28 PM
    Friday, June 14, 2019 12:56 PM
    Moderator

All replies