Disable Choice Field On Edit Form in SharePoint 2016

Disable Choice Field On Edit Form in SharePoint 2016

In this post, we will explain How to Disable Choice Field On Edit Form in SharePoint 2016 using JQuery?

Disable Choice Field On Edit Form in SharePoint 2016

You might also like to read Show / Hide fields based on choice field selection using JQuery in SharePoint


Disable Choice Field On Edit Form in SharePoint 2016

In SharePoint 2016, I have a custom list “Project Tasks” with content type enabled, In this content type, I have a choice field called “Project Status”, I would like to disable choice field on Edit Form and New Form.

Disable Choice Field in SharePoint forms

You might also like to read Disable SharePoint Field Using JQuery


Disable Radio Button on Edit form using JQuery in SharePoint

In this section, we’ll show how to set a SharePoint Choice field and disable Radio Button on Edit form using JQuery

Steps

  1. Open your list.
  2. From the above ribbon, Click on the List tab.
  3. In “Customize List”, Click on “Form Web Parts”.
  4. Select “Default Edit Form” to customize the default edit form.
Default Edit Form in SharePoint
  • Click on Add new Web Part.
  • In the “Media and Content” category, Add Script Editor web part.
  • Edit the snippet.
Add Script Editor in SharePoint 2019

Add the below code with your own Choice field / Radio Button field ID

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"
       type="text/javascript"></script>
<script type="text/javascript">
$(function() {
//Disable Choice Field in SharePoint
$("input[id^='Project_x0020_Status']").attr('disabled', 'disabled');
}); 
</script>
Set Choice Field as Read Only in SharePoint 2016

Note: Use F12 developer tools to get the first part of your field ID

Get ID of Choice Field in SharePoint using developer tools

Hide Choice Field on Edit form using JQuery in SharePoint

Besides, Disable Choice Field On Edit Form in SharePoint 2016, you may also need to hide

  1. Open your list.
  2. From the above ribbon, Click on the List tab.
  3. In “Customize List”, Click on “Form Web Parts”.
  4. Select “Default Edit Form” to customize the default edit form.
Default Edit Form in SharePoint
  • Click on Add new Web Part.
  • In the “Media and Content” category, Add Script Editor web part.
  • Edit the snippet.
Add Script Editor in SharePoint 2019

Add the below code with your own Choice field / Radio Button field ID

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"
       type="text/javascript"></script>
<script type="text/javascript">
$(function() {
//Disable Radio Button in SharePoint
  $("input[id^='Project_x0020_Status']").closest('tr').hide(); 
}); 
</script>

Hide Column In SharePoint Forms Using PowerShell

You can also use SharePoint Power-Shell to hide a field in

  • New Form (ShowInNewForm).
  • Edit Form (ShowInEditForm).
  • Display Form (ShowInDisplayForm).

Note: The Power-Shell Script is not working for the system generated column like Task Name, Description ….etc.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$web = Get-SPWeb -Site http://devoworx/
$listname = "Project Tasks"
$fieldName = "Project Status"
$list = $web.lists | Where-Object { $_.title -Eq $listname } 
$list | Format-Table title,id -AutoSize
$field = $list.Fields[$fieldName] 
$field.ShowInEditForm=$false;
$Field.Update()

You should also check this PowerShell Script that helps you to manage showing and hiding fields in new, edit and display form in SharePoint at Show and Hide Columns in SharePoint List Forms Using PowerShell.


Applied To
  • SharePoint 2019.
  • SharePoint 2016.
  • SharePoint 2013.
Conclusion

In this post, we have explained How to JQuery or Power-Shell to

  • Disable Choice / Radio button field in SharePoint Forms.
  • Set Choice / Radio button field as Read-only in SharePoint Forms.
  • Hide a Choice / Radio button field in SharePoint Forms.
Download

You can also explore other JS snippet SharePoint on GitHub. Please, don’t forget to Follow Me to get the latest updates.

You might also like to read
Have a Question?

If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.

Leave a Reply