none
Need to restrict the document name length to 40 chars while uploading document in SharePoint library RRS feed

  • Question

  • hi,

    need to limit the length of the document name while uploading the document using the upload link button in library.

    i tried to apply JavaScript to do the same by linking it with CEWP but it didnt work.

    need to know the name of the property or function that i can use to call the upload document, so that i can validate the char length of the filename that i have selected to upload in the library.

    following is the js code i have used:

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

    $(#QCB1_Button2).onclick(function()
    {
    var filename = document.getElementById('name').value;    

    if(filename.length>40)
            {
            alert("File name is too big. It should be less than 40 characters.");
                    return false;
            }
            else
            {
                    alert("valid Format");
                    return true;
    }
    }

    </script>
    Friday, January 20, 2017 11:57 AM

All replies

  • You may want to look at webhooks now. Using hooks you can write event handler and control the behavior.

    Thanks, Ashish | Please mark a post helpful/answer if it is helpful or answer your query.

    Friday, January 20, 2017 12:23 PM
  • Hi Falguniv,

    We can override the CheckAssetLibMediaExtension function in upload.aspx to check the file name length, the upload page is located at the path:

    C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\upload.aspx

    More information and the detailed steps, please refer the article below:

    SharePoint - Check File Name in Upload form in Document Library with Javascript

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 23, 2017 9:11 AM