Make fields Disable / Read only on Entry Forms

If you want to disable fields on New Entry Form or Edit Entry form, Use this code to disable fields :


// Function To Disable Fields
  function disableField(title)
  {
   for(var i = 0; i < document.all.length; i++)
   {
    var el = document.all[i];
    // find html element with specified title
    if(el.title == title)
    {
     el.disabled = true; // disable
     // if the next element has a reference to the current element
     // then disable if as well
     if(i < document.all.length - 1)
     {
      var el2 = document.all[i + 1];
      if(el2.outerHTML.indexOf(el.id) > 0)
      {
       el2.disabled = true;
      }
     }
     break;
    }
   }
   }
   // END Function To Disable Fields 



Call Function within entry form :
disableField("Task Description");
disableField("Comment");
disableField("Status");

Comments

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

Change Language for current user with JSOM in SharePoint Online

SharePoint 2010 CSS Chart