Make Column Read-Only in Edit Form
-
15-12-2020 - |
Question
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.
Solution
You can use SPUtility.js for hide and read only fields in SharePoint forms.
Reference link: https://sputility.codeplex.com
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange