Home > Blockchain >  JQuery How can display datepicker properly?
JQuery How can display datepicker properly?

Time:11-30

everyone, do you know what wrong with this datepick ? I expect to see a calendar, not time picker.

I use bootstrap example file with the below link and script which are from youtube tutorial

<section class="row gy-3">

  <div class="form-group">
      <div class='input-group date' id='datetimepicker1'>
          <input type='text' class="form-control" />
          <span class="input-group-addon">
              <i class="bi-alarm"></i>
          </span>
      </div>
  </div>

</section>
<script type="text/javascript">
  $(function() {
      $('#datetimepicker1').datetimepicker();
  });
</script>

I use bootstrap example file with the below link and script which are from youtube tutorial

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <!-- Bootstrap core CSS -->
    <link href="../assets/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="../assets/dist/js/bootstrap.bundle.min.js"></script>
    <script src="form-validation.js"></script>

enter image description here

CodePudding user response:

here in you have added datetimepicker css and js so that time call both function like date and time so use below css and js to import and work great

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css">
     <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
  $(function() {
      $('#datetimepicker1').datetimepicker();
  });
</script>

replace with below url

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>

<script type="text/javascript">
        $(function() {
            $('#datetimepicker1').datepicker();
        });
    </script>
  • Related