Hide SharePoint 2013 List form fields
Hi SharePoint buddies & lovers, after long I started to post SharePoint topics those comes my way and quite interesting ones.
SharePoint developers sometimes may need to hide and show
form controls in list forms. As per business rules you need to hide certain
fields in new, edit, or display forms or conditionals [select country
-> show states]. Here is the simple solution to hide fields using basic jQuery to catch location of the field names. We are all know that list form
controls are enclosed with table row and each control and it’s field name enclosed
in a table cells.
New & Edit Forms
In new and
edit forms field names are enclosed with <nobr> tag, nearest tr of <nobr> tag
represents the whole row of field.
(document).ready(function() {
$('nobr:contains("Location")').closest('tr').hide();
});
Display Forms
In display
form field names are enclosed with table cells, parent of table cell represents
the whole row of field.
$(document).ready(function() {
$('td.ms-formlabel:contains("Location")').parent().hide();
});
Comments
Post a Comment