Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds


  Asked By: Carlton    Date: Feb 07    Category: Sharepoint    Views: 2164

hw do you set the property readonly using jquery.



9 Answers Found

Answer #1    Answered By: Daamodar Bhadranavar     Answered On: Feb 07

What property? If it's a server-side property, then you're going to have
some work ahead of you.

Answer #2    Answered By: Destiny Lewis     Answered On: Feb 07

Where do you want to do this? On an .aspx page?

Answer #3    Answered By: Tanisha Rowe     Answered On: Feb 07

Are you talking about making a field on a list form readonly?

Answer #4    Answered By: Sierra Lewis     Answered On: Feb 07

i want to make a field readonly..

Answer #5    Answered By: Dwight Becker     Answered On: Feb 07

I use the SmartTools jQuery for SharePoint solution available here to
make jQuery available to me:


And then on the edit form that I want to have read only fields I add a
Content Editor Web Part with the following code in it. Rather than set
the field to "readonly" this will make the field non-editable. I have
found that if I set  a field to readonly, the value in the field is
blanked out when the form is submitted back and thus you lose the very
value you were trying to lock down

<script language="javascript" type="text/javascript">

// Determines if the web part page is in design mode

// by looking at hidden fields produced by SharePoint

function IsInDesignMode()


if(document.getElementById("MSOLayout_InDesignMode").value == '1')
return true;

if(document.getElementById("MSOTlPn_SelectedWpId").value != "")
return true;

return false;


function kickStart() {

$(":input[title='Batch Status']").attr('disabled', true);

$(":input[title='Report Type']").attr('disabled', true);


if (IsInDesignMode() != true) {




Answer #6    Answered By: Amar Kumbar     Answered On: Feb 07

I'm interested in what I consider to be extraneous code...

I would have considered only to use:

<script type="text/javascript" src="jQuery.js" />
<script type="text/javascript">

$(document).ready(function() {
$("input[title='Batch Status']").attr('disabled', true);


Instead, you have a bunch of stuff running that determines whether or not the
system fields have some set  values. Is this behaviour necessary when you use the
SmartTools? Are you loading the jQuery library on each page? (...cached, I'm
certain, but still!)

Answer #7    Answered By: Marc Dixon     Answered On: Feb 07

In answer to your questions:
Your solution does pare the code required down to the very bare minimum.

If you use the SmartTools solution, the jQuery library is loaded on
every page and yes it would be cached. I use jQuery all over the place
so it's easier for me to do it that way.

I use that custom IsInDesignMode() function in combination with the

instead of just $(document).ready(function() {}

because it allows to me to go into design mode on a page and not have
the custom javascript code running.

Answer #8    Answered By: Johathan Mcgowan     Answered On: Feb 07

That is definitely an obnoxious aspect of going into Edit
Mode...I will look more deeply into this idea. We are already determining the
usefulness of using the SmartTools because we need to centralize our jQuery
hosting for our Farms. This may add a boost to its need (O;

Answer #9    Answered By: Georgia Barr     Answered On: Feb 07

consider this project as well:

Didn't find what you were looking for? Find more on Jquery Or get search suggestion and latest updates.