Has any one tried inserting Attachment control in Newform and Display form using Jquery with out going for Custom forms from Designer. I know we can add an attachment control through designer.

When i look at the DOM there is a class called .MS-formtable. Can i insert a attachment control with appending to this table by using the class name. Attached is the DOM model.enter image description here

We can use Display templates (CSR)??


By default, the Attachment is hidden in list form. We can add the CSS style into script editor web part in display/new form page.

<style type="text/css">
    display: black !important;

enter image description here

If you don't want to use the Ribbon to attach file, we can use the code below to add the attach file control into a row of table.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var attachHTML='<tr><td width="190" height="15" class="ms-formlabel" valign="top">Attach File</td><td height="15" class="ms-formbody" id="attachmentsOnClient" valign="bottom"><span dir="ltr"><input name="fileupload0" title="Name" class="ms-fileinput" id="onetidIOFile" type="file" size="56"></span></td></tr><tr><td>&nbsp;</td><td><input class="ms-ButtonHeightWidth" id="attachOKbutton" onclick="OkAttach()" type="button" value="Attach"><span class="ms-SpaceBetButtons" id="idSpace"></span><input class="ms-ButtonHeightWidth" id="attachCancelButton" accesskey="C" onclick="CancelAttach()" type="button" value="Cancel"></td></tr>';

enter image description here

| improve this answer | |
  • <style type="text/css"> #idAttachmentsRow{ display: block !important; } </style> Just a minor mistake in CSS. – Sohail Shaikh Oct 17 '18 at 5:34
  • I don't see that in default view the name of the attachments which have done.How can we get that in default view – santosh kondapalli Oct 17 '18 at 10:24
  • If you want to show attachments in list view, check this: social.technet.microsoft.com/Forums/en-US/… – LZ_MSFT Oct 18 '18 at 1:15

You can try Stratus Forms. It uses jQuery and SPServices to build a nice and easy forms in SharePoint.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.