Created
March 19, 2014 00:44
-
-
Save MatthewSteeples/9633296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model DateTime? | |
@{ | |
string name = ViewData.TemplateInfo.HtmlFieldPrefix; | |
string id = name.Replace(".", "_"); | |
bool monthEndOnly = ViewBag.MonthEndOnly ?? false; | |
} | |
@Html.TextBoxFor(model => model, new { style = "DatePicker" }) | |
<i class="icon-calendar"></i> | |
<script type="text/javascript"> | |
$(function () { | |
$("#@id").datepicker({ | |
@if (monthEndOnly) | |
{ | |
<text> | |
beforeShowDay: function(date) | |
{ | |
// getDate() returns the day [ 0 to 31 ] | |
if (date.getDate() == | |
(new Date((new Date(date.getFullYear(), date.getMonth() + 1, 1)) - 1)).getDate()) | |
{ | |
return [true, '']; | |
} | |
return [false, '']; | |
}, | |
</text> | |
} | |
dateFormat: 'dd/mm/yy', | |
changeMonth: true, | |
changeYear: true, | |
showOn: "button" | |
}); | |
$("#@id").val($("#@id").val().substring(0, 10)); | |
$("#@id").addClass("dateITA"); | |
$(".icon-calendar").click(function() { | |
$(this).prev(".ui-datepicker-trigger").click(); | |
}); | |
$("#@id").focus(function() { | |
return false; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment