Set task list title textbox to readonly mode in Sharepoint 2007
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
- In the same way find out the textbox name by selecting the page view source of Editform.aspx
- 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–>
- 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
Comments
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 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.