I only need to just 'lock' some of the fields. How to do it?

Mar 31, 2010 at 11:34 AM

This is a brillian solution, if only I could make it work.

To do that I need someone to please try to explain this in a more descriptive way so that us "non-javascript professionals" can understand!

I have added the webpart and if I add i.e. "?Title=This is a test" to the end of the URL for the editform.aspx it shows the "Title" field greyed out an pre-filled. So apparently something is working!


How do I lock down the fields/columns one by one in the script or on the page!? Where in the script do I have to add them and what are the tags/commands!?

In example i want to lock(grey out) the first two fields in my editform.aspx:


Shoe size


Responsible person


What do I need to write, and where, to accomplish this?


Christopher R




Apr 4, 2010 at 2:37 PM


The script was designed for near-zero configuration.  You just create your URL with &Title=_ to lock the title field.  Look over the second example again on the home page.

Apr 6, 2010 at 11:28 AM


Thanks for your reply Autosponge. So in other words this script won't help much when using it from a list, not a customized URL to a specific form!? 

I need the first fields in the form to be locked when someone opens it for editing from the list (editform.aspx). This is usually done by the users by clicking the menu (that appears when hovering an item title) for an item in the list an click "Edit Item". Is this not possible in any way? Does it only work with custom URL's and not in standard lists?


May 12, 2010 at 9:32 AM
Edited May 12, 2010 at 9:33 AM

Sorry, I think I can make myself i little bit more clear:

How do I apply these changes to the form fields (hiding/locking/and so on) without adding stuff to the back of the URL?!  I want to apply it to the newform.aspx form permanently.

BTW: I'm a rookie on Javascripts, but eager to learn :)

May 13, 2010 at 1:58 PM
You could add a script that manipulates the URL on pageload before starting $.spff(). You can also try changing the script to have default params (key-value pairs that would normally come from the url): jQuery.spff = function(options){ if (params[0]===""){ return false; //break do not continue } changes to jQuery.spff = function(options){ if (params[0]===""){ params = [['key1', 'value1'], ['key2', 'value2']]; }
Aug 5, 2010 at 2:56 PM

Hey guys,

If you need to lock down an individual form element and you don't want to navigate to that form with a customized query string, then use the following code example (you will need to add this code to a content editor web part on the form page):

<script language="javascript">

function lockFields()

  var theInputTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");

  alert(" Title: " + theInputTitle.value);

  theInputTitle.disabled = true;

  function getTagFromIdentifierAndTitle(tagName, identifier, title)
    var len = identifier.length;
    var tags = document.getElementsByTagName(tagName);
    for (var i=0; i < tags.length; i++)
       var tempString = tags[i].id;
       if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
         return tags[i];
    //return null;




Sep 27, 2010 at 2:49 AM

@autosponge - Like everyone else, I am loving this script. Do you have any plans to modify it so as to allow multiple options on a per field basis? i.e.

  • Lock and Set field(s)
  • Hide and Set field(s)

Background and color attributes for Lock could/should remain global for consistency.

@chr_ramsdal - This solution was designed to allow you to pass values from a hyperlink to specified fields in a NewForm. If you wanted to lock editing to certain fields in EditForm pages you could do this by customising the List Form in SharePoint Designer and simply hiding the fields you want. Bear in mind you would be customising a page from the List Definition, unless you chose to create new Custom List Form pages.

Sep 27, 2010 at 1:51 PM

@panoone - Do you want to lock on a per-field basis from the script configuration or from the URL?  The original idea, when I wrote this, was to not do configuration on every page--just add the script and use it.  The problem I see with doing additional configuration from the URL is the URL length does have a limit (depends on the browser) and I don't want to reduce the effectiveness on large forms/long text data.

Sep 28, 2010 at 10:01 AM
Yes, the more I play with it, the more I can see your point. All or nothing isn't such a bad option.

Perhaps, though, an * or other unlikely character could be used as a prefix to the field value in order to set selective locking via the URL??

In any case, I'm simply loving the functionality it provides...which some might say should have been present in the first place. ;)