The application that I’m working on has a common datepicker format setup. All pages inherit the following javascript in the header:
$(document).ready(function () {
$(':input[data-datepicker]').datepicker({ dateFormat: 'mm-dd-yyyy' });
});
Now I have a page where I need to add my own properties to the Datepicker such as get the MaxDate property setup:
Reference:
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.18.min.js")" type="text/javascript">\</script>
.
.
.
// Setting Datepicker properties.
// ( I want today's date to be the max date a user can pick: )
$(function () {
$('#addDate').datepicker({ maxDate: 0 });
});
.
.
.
Rendered HTML:
<input data-datepicker="True" id="addDate" name="Date" type="text" value="" />
Right now no additional properties I add to $(‘#addDate’).datepicker , such as MaxDate or defaultDate seem to be taking effect. Help!
Odd one but I solved it. It did it when instead of using options I overwrote it with a function: