Add date picker in SharePoint 2013 using JavaScript Object Model (jsom)

Here we will check how to add date picker in SharePoint page using SharePoint javascript object model. Here in this post, we will see how the date validation work means like start date should not be greater than the end date. And also End should not be less than the start date.

Write the below code using script editor web part in a web part page in SharePoint 2013/2016/Online.

<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css” />
<script src=”http://code.jquery.com/jquery-1.8.3.js”></script>
<script src=”http://code.jquery.com/ui/1.10.0/jquery-ui.js”></script>

<script>
$(document).ready(function() {

$( “#fromdatepicker” ).datepicker({
onClose: function( selectedDate ) {
$( “#todatepicker” ).datepicker( “option”, “minDate”, selectedDate );
}
});

$( “#todatepicker” ).datepicker({
onClose: function( selectedDate ) {
$( “#fromdatepicker” ).datepicker( “option”, “maxDate”, selectedDate );
}
});

});
</script>
From Date: <input type=”text” id=”fromdatepicker” />
To Date: <input type=”text” id=”todatepicker” />
<input type=’button’ value=’Export Data to Excel’ onclick=”retrieveListItems();”/>

<script language=”javascript” type=”text/javascript”>
function retrieveListItems() {
var startDate = $(“#fromdatepicker”).datepicker(“getDate”);
var endDate = $(“#todatepicker”).datepicker(“getDate”);
alert(startDate);
alert(endDate);
}
</script>

Add datepicker in SharePoint 2013 using client object model

Add datepicker in SharePoint 2013 using client object model

Add datepicker in SharePoint 2013 using client object model

Add datepicker in SharePoint 2013 using client object model

You may like following SharePoint jsom tutorials:

Hope this tutorial helps to add date picker in SharePoint 2013 using JavaScript Object Model (jsom).

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>