JQuery Calendar Validations of Start, End dates.

by Yashwanth M

HTML

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/black-tie/jquery-ui.min.css">
<div style="padding-bottom: 50px;">
    <label>Location: </label>
    <input type="radio" name="locate" value="Internal">Internal
    <input type="radio" name="locate" value="External">External
</div>
<div>
    <label>jquery date picker: </label>
    <input type="text" name="dueDate" id="dueDate" size="25" placeholder="Please Enter A Due Date" autocomplete="off" readonly="true">
</div>

CSS

// https://stackoverflow.com/q/47807211/5081877

JavaScript

$("input[name='locate']").click(function() {
    locate = this.value;
    var dateField = $('#dueDate');
    
 if ($("input[name='locate']:checked").val() == 'Internal'){
     dateField.datepicker('destroy');
     dateField.datepicker( { minDate: '-6D', maxDate: '+6D' });
 }
 else {
     dateField.datepicker('destroy');
     dateField.datepicker( { minDate: -0, maxDate: '+6D' });
 }
 
});