Tuesday, 2 February 2021

Datetimepicker - Display only date and remove time

 

 Watch this example on YouTube


 

 

@{
    ViewBag.Title = "Home Page";
}
<input type="text" id="dt1" />
<input type="text" id="dt2" />
<input type="submit" onclick="test()" />
<link href="~/Content/jquery.datetimepicker.css" rel="stylesheet" />
@section Scripts{
<script src="~/Scripts/jquery.datetimepicker.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dt1').datetimepicker();
        });

        function test() {
            $('#dt2').val($('#dt1').val().split(' ')[0])
        }
    </script>    
}

 

No comments:

Post a Comment