-1

I have Date in SharePoint server 2013 and I want to add 14 days on it by jQuery

I have the column name EndDate text type.

2
  • You said add 14 days? From what date you want to add? Commented Jul 31, 2016 at 14:29
  • from current Date? Commented Jul 31, 2016 at 14:29

1 Answer 1

0

You can do this by attaching a JSLink file to the edit/new form webpart.

On that file use something like

(function () {
   var ctx = {};
   ctx.Templates = {};
   ctx.Templates.Fields = {
       'EndDate': { 'NewForm': renderEndDateField }
   }
   SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
})(); 


// This function provides the rendering logic 
function renderEndDateField() { 
    var today = new Date();
    var endDate = new Date();
    endDate.setDate(today.getDate()+14);
    var day = endDate.getDate();
    var month = endDate.getMonth();
    var year = endDate.getFullYear();
    ctx.CurrentFieldValue = day + '-' + month+1 + '-' + year ;
    return SPFieldText_Edit(ctx);
}

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