$(function() { $("input.questionDate").datepicker({ dateFormat: 'mm/dd/yy' }); $("input.questionDate").each(function(){ var currentValue = $(this).val(); if(currentValue) $(this).datepicker('setDate',new Date(currentValue)); }); $("input.questionDate").keydown(function(event) { if(event.keyCode != 8){ event.preventDefault(); } }); });
Start Date: <input class="questionDate" value=" 05/16/2015 "> <br> End Date: <input class="questionDate" value=" 05/31/2015 "><br>