Set task list title textbox to readonly mode in Sharepoint 2007

5 September, 2008 (14:23) | MOSS - Customization with SPD | By: GVK

One of my client asked to set the task list title textbox to readonly mode when the user selects edit item property from the context menu.
So, I thought to complete this scenario by making use of javascript

  • Open the EditForm.aspx in Sharepiont designer
  • Select one td tag to write the javascript which sets the Title textbox to readonly mode
  • First of all write <script language=”javascript”>
  • Then document.<formname>.<textboxname>.disabled=”true”;
  • In the above step form name can be found by selecting the page view source of Editform.aspx
View source of EditForm.aspx to find out form name

View source of EditForm.aspx to find out form name

  • In the same way find out the textbox name by selecting the page view source of Editform.aspx
View source of EditForm.aspx to findout textbox name

View source of EditForm.aspx to find out textbox name

  • At last your script looks like this

<!–Textbox Readonly Script Starts Here–>

<script language=”javascript”>
document.aspnetForm.
ctl00$m$g_99782022_7721_4b5a_baa3_ac4b844844dd$ctl00$ctl04$ctl00$ctl00$ctl00$ctl04$ctl00$ctl00$TextField.
disabled=”true”;
</script>

<!–Textbox Readonly Script Ends Here–>

Readonly script in Sharepoint designer

Readonly script in Sharepoint designer

  • Add the script tag in some td (example:<td>Script goes here…</td>) as shown in above image
  • Save EditForm.aspx in Sharepoint designer and browse in explorer, now you can view the Title textbox is set to readonly mode, means users cannot edit the Title textbox
Title textbox set to readonly mode

Title textbox set to readonly mode

Comments

Comment from Elmer
Time December 5, 2008 at 9:28 pm

I tried this javascript as indicated in image #3, using SPD and the correct form and textbox names for my list. It did make the field readonly but it deletes the previous content of the readonly field after I save my other changes through the EditForm. Please let me know if I’m missing something.

Comment from Tim
Time March 19, 2009 at 10:38 am

Hi thanks for this nice tip,
i’m having the same problems as Elmer.
I tried this with a Task List. Added a new Task with priority = “(3)low”. Set “priority” to Read-Only. Opened the taskitem again with editform.aspx : “priority” was readonly – so the script is working well. But when i did some changes to the other fields of the taskitem, “priority” was set to “(1)high”.

any ideas ?

Comment from Rajender
Time December 17, 2009 at 6:27 am

where editform.aspx located in sharepoint.. can u please help to me… urgent

Comment from Rajender
Time December 18, 2009 at 6:55 am

if change done in the editform.aspx title text was not able to disable.. please help me out

Comment from Labhesh
Time February 2, 2010 at 4:04 pm

Hi, I would like to same thing to be done, but with hyperlink field, so that user can’t edit in edit mode but should be able to click the link. please help.

Comment from G Vijai Kumar
Time February 3, 2010 at 5:33 am

@ Labesh: Please use Office Toolbox solution available at Codeplex, you can find the solution at http://officetoolbox.codeplex.com/
Let me know in case if you need more information, thanks for looking into the post.

Comment from Labhesh
Time February 4, 2010 at 11:01 pm

Thanks a lot, it is quite usefull. i am gonna try this. labhesh

Comment from shiva
Time May 7, 2010 at 10:08 am

Thanks for ur Info.. It was very helpful.. can u give me updates regaring ur post to my mail..

Comment from manoj2784
Time May 28, 2010 at 4:50 pm

on updating the data already exisitng in the field is lost

Comment from Joanne
Time October 15, 2010 at 9:31 am

I’m struggling to find the EditForm.apsx file to edit.
Can anyone help with where I will find this. I can find the DispForm.aspx file, should it be in the same folder?

Comment from G Vijai Kumar
Time October 15, 2010 at 8:18 pm

@ Joanne: You can find the EditForm.aspx when you open the site in SharePoint designer under lists fodler, Good Luck

Comment from Hari Gillala
Time November 1, 2010 at 9:15 pm

Hi GVK, When u put this form field in disabled state, The already existing valus in disabled mode is not being treated as a value and if that is required field then its coming as validation required field error.

How could we resolve this issue, look forward for the reply.

Thank you,
Hari Gillala

Comment from hari
Time November 4, 2010 at 11:00 am

when u keep the field disabled, if it was arequired field then the existing value is not being submitted. How to solve this?

Comment from G Vijai Kumar
Time November 5, 2010 at 4:59 am

@ Hari: Please use http://officetoolbox.codeplex.com/ I guess using the CodePlex solution you will be able to meet your requirement, let me know if you require any other information

Comment from Hari Gillala
Time November 5, 2010 at 9:13 am

Hi GVK, Thanks for replying to the post. I have tried to install codeplex code on some machines I can see the feature being installed and on other machines it being installed but the feature is not availble.

Comment from saket
Time March 14, 2011 at 6:46 am

hi,
I used the above but it looses value on postback (e.g. when we have validation postback)

Comment from Durai
Time September 8, 2011 at 11:54 am

use readOnly, instead of disabled

Write a comment