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
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