Datetimepicker erases value from input if value exists at page load

I am using this datetime collector for Bootstrap 4 https://tempusdominus.imtqy.com/bootstrap-4/

The plugin works just fine if the input is empty at boot time. However, I have an Edit form that already has a value, but datepicker deletes the value when the page loads.

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <div class="form-group">
               <input class="form-control datetimepicker-input" data-target="#Entry_EntryDate" data-toggle="datetimepicker" data-val="true" data-val-date="The field Event Date must be a date." data-val-required="The Event Date field is required." id="Entry_EntryDate"  type="datetime" value="2017-10-25 10:17 AM" />
            </div>
        </div>
    </div>
</div>

and default js

 $(function() {
         $('#Entry_EntryDate').datetimepicker();
 });

Here is the JsFiddle

I developed the recommended jsfiddle, so I am sure that I have all the necessary necessary dependencies.

I tried changing the locales by changing the formats, but no luck.

+4
source share
1 answer

datetimepicker, , , , $('#Entry_EntryDate').val() date timepicker :

js

 $(function() {
     var date = moment($('#Entry_EntryDate').val(), 'YYYY-MM-DD hh:mm a').toDate();
     $('#Entry_EntryDate').datetimepicker({date:date});
 });
+4

Source: https://habr.com/ru/post/1688183/


All Articles