Past Date Validation In SharePoint

Keep the field text id ready from the input code line in order to map it to the required past date selection validation ie. Selected Date <= Today

  1. <input type="text" class="input-field datefilingcls hasDatepicker" id="txt_dateofintimation" name="field1" readonly="">  

Create a JQ function representing link to that field's id “txt_dateofintimation” for selecting only past dates and the max date is today only with a gap of 3 months. 

  1. $(document).ready(function() {  
  2.     loadBlankPage();  
  3.     var dateToday = new Date();  
  4.     $("#txt_dateofintimation").datepicker({  
  5.         numberOfMonths: 3,  
  6.         showButtonPanel: true,  
  7.         maxDate: dateToday  
  8.     });  
  9. })   
Go to that site's page and start filling in the details.
Here is the validation pop up for Date field to be selected.



Current date is 17th May 2017 as shown below in the bottom bar and the function also allows us to select the dates before today as per the validation requirement.
Ebook Download
View all
Learn
View all