0

I am attempting to lock down some fields in the Edit Form so that the data cannot be accidentally changed.

I am knowledgeable of how to use script and content editor web parts, so I am able to insert script.

I tried this script, but it did nothing:

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"
       type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function()
{
//Set the Field to Read only and change its background colour
$("input[title='Metrics ID']").attr("readonly","true").css('background-color','#F6F6F6');
//You can disable the field also:  $("input[Title='Metrics ID']").attr("disabled", "disabled");
});

</script>

Any advice or resources would be very appreciated. Thanks! Oh, and I am working in SharePoint 2013.

2

You can use SPUtility.js for hide and read only fields in SharePoint forms.

Reference link: https://sputility.codeplex.com

  • Thanks. Is this easy to implement for someone who is not familiar with javascript? – cbbrown Feb 23 '17 at 15:11
  • Yes very easy just need to add this JS reference file and then put your read-only code in document.Ready(). – Samir Khimani Feb 23 '17 at 15:15
  • Add the reference file to the Site Assets and connect to it with a Content Editor? Sorry, I've only done what I consider simple script additions. – cbbrown Feb 23 '17 at 15:18
  • Yes add file into site assets and then reference that file into content editor web part. – Samir Khimani Feb 23 '17 at 15:55
  • Got it. I found this step by step guide. sputility.codeplex.com/… Thanks for your help! – cbbrown Feb 23 '17 at 16:05

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.