Reputation: 60
I am using SharePoint DateTimeControl to capture a DateTime value. Customer is requesting to limit the time part of the control to only accept time from 7:00 AM to 6:00 PM for example.
I get back to the reference of the MSDN but all what I can get is the MaxDate and MinDate properties.
I tried to play with those properties as suggested in this post with no luck.
Any recommendation?
Upvotes: 0
Views: 237
Reputation: 4208
We can use JavaScript code below to achieve it.
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(function(){
$("select[name$='Hours'] option").each(function(){
if($(this).val().match(/^(([1-6]|12) AM)|(([7-9]|1[0-1]) PM)/g)) {
$(this).remove();
}
});
});
</script>
Upvotes: 1