Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

how to place JS-code to NewForm.aspx of a list in SharePoint 2013 APP.

In sharepoint 2010 we can use this list definition to add JS:

<List ...>
    <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" UseDefaultListFormWebPart="False">
          <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="1">
            <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
              <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>                         
              <sfwp:Content>ANY HTML YOU NEED HERE
          <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="2">
            <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
              <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>                         

How to do the same for Sharepoint 2013?

share|improve this question

2 Answers 2

From the Ribbon click on List -> Form Web Parts -> Default New Form

enter image description here

Click on Add a Web Part -> Media and Content -> Content Editor

Edit the Content Editor web part and put in the link to the JavaScript file

  • I store the js files at /SiteAssets/js/
  • From a sub-site you can link by using: ../SiteAssets/js/customjs.js
  • Make sure that the js file is formatted using html script tags
share|improve this answer
how to do this in xml? –  Pantani Aug 22 '14 at 8:59

What exactly are you trying to do with the JS? Is it for a specific column or for the whole form? There are some new things, but it depends on what you are actually trying to do. If it's for a specific column, there's a new JSLink attribute for a that lets you add JS to the column and change how it's rendered in all locations, but that is specific to the column. It would allow you to do something like implement a cascading selection for a column, something quite tricky to do and would only work on a specific form... this new way lets you control it for everything.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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