locked
javascript readonly multiline textbox in sharepoint form RRS feed

  • Question

  • I have a sharepoint custom form and wanna to set some multiline field readonly on it with java script or jquery.

    I try this commands:

    alert($("textarea[title='m']").attr('readonly'));
    $("textarea[title='m']").attr('readonly', 'readonly');
    alert($("textarea[title='m']").attr('readonly'));

    the first alert show: false

    second alert show: true

    but the field is not readonly. I use the same code and replace 'textarea' with 'input' for other fields and it works ;O ;O

    Any solutions???????????


    • Edited by Somatco Tuesday, October 22, 2013 3:47 PM
    Tuesday, October 22, 2013 3:44 PM

Answers

All replies

  • Hello,

    Did you try this?

    http://stackoverflow.com/questions/3297923/make-textarea-readonly-with-jquery

    Hope it could help


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, October 23, 2013 9:19 AM
    Moderator
  • I try it:

    $('input[type="text"], textarea').each(function(){$(this).attr('readonly', 'readonly'); });

    and it:

    $('input[type="text"], textarea').attr('readonly', 'readonly');

     but no one works, and the textbox is not readonly...

    Friday, October 25, 2013 10:12 AM
  • How about this?

    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/450d0e6b-d340-4b4d-b8ee-9ba02fcbebbb/use-javascript-to-disable-a-multiline-rich-text-field?forum=sharepointcustomizationlegacy


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Friday, October 25, 2013 10:27 AM
    Moderator
  • I try this:

    <script type="text/javascript">

    $(document).ready(function () {DisableRichTextField('m');});

    function DisableRichTextField(title){

                                    var richEditor = getTagFromIdentifierAndTitle("Textarea","TextField",title);

                                    var iframeID = RTE_GetEditorIFrameID(richEditor.id);

                                    var elemTextArea=RTE_GetEditorTextArea(richEditor.id);

                                    var editor = document.getElementById(iframeID);

                                    if (editor != null){editor.outerHTML = "<div style='background-color:white;border:1px solid #c4c4c4;color:silver;width:386px;height:84px'>" + elemTextArea.value + "&nbsp;</div>";}}</script>

    and this:

    <script type="text/javascript">

    $(document).ready(function () {HideTextAreaField('m');});

    function HideTextAreaField(title){var theTextAreaBox= getTagFromIdentifierAndTitle("textarea", "", title)

                    if (theTextAreaBox!= null){theTextAreaBox.parentNode.parentNode.parentNode.style.display ="none";}}</script>

    and in both cases I got runtime error:

    Friday, October 25, 2013 5:26 PM
  • Hello,

    May be some problem with your browser. Did you try in different browser?

    Also take a look at here to disable error popup:

    http://help.yahoo.com/l/qe/snova/toolbar/features/popupblocker/stillgetting/pub-08.html

    http://www.taxact.com/tsupport/FAQDisplay.asp?Question=556


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, November 6, 2013 5:38 AM
    Moderator
  • Hi Samato,

    Pls try this. Use firbug or any developer tools to get the ID of the control.

    $("textarea[id='<ID of text area>']").attr('readonly', 'readonly');

    Regards,


    Sairam Avacorp Technologies

    Wednesday, November 6, 2013 6:20 AM
  • I know that this question has been asked for a long time, but I would like to share this article "Disable SharePoint Multiline TextBox Field In Edit Form"   that may be helpful for all future users like me!

    This code is working like charm for me

    $("textarea[title='column title']").attr('readonly', 'readonly');

    I think Using title instead of id will not require developer tools, find the details here



    • Edited by Joun Martin Saturday, June 13, 2020 2:02 PM
    Saturday, June 13, 2020 1:58 PM