从 Eternicode 引导日期选择器,而不是选择日期

bootstrap datepicker from eternicode not selecting date

本文关键字:日期 选择 选择器 Eternicode      更新时间:2023-09-26

我现在正在使用 bootstrap 3.0 和 eternicode 的 bootstrap-datepicker 来处理这个输入。

问题是默认情况下我禁用了输入,因为我不希望用户手动修改日期。

我正在分配一个带有日历字形的输入插件以显示日期选择器。但问题是,每当我选择一个日期时,输入都不会收到日期。我一直在浏览文档,有一种方法可以做到这一点,但它仅适用于 Bootstrap 2.3.2。

这是我的代码,有谁知道如何将所选日期从日期选择器转移到我禁用的输入中?

帮助将不胜感激!

.html

<div class="form-group">
     <label class="control-label" for="fechaTandas">Fecha</label>
      <div class="input-group">
     <span class="input-group-addon date" id="trigger-datepicker"><span class="glyphicon glyphicon-calendar"></span></span>
   <input type="text" class="form-control" name="fechaTandas" disabled="disabled" id="fechaTandas" placeholder="seleccione una fecha">
 </div>

.js

//JS to trigger the datepicker
$('#trigger-datepicker').datepicker({
     format: "yyyy/mm/dd",
    language: "es"    
});

这是永恒代码日期选择器插件的链接:

http://eternicode.github.io/bootstrap-datepicker

我认为您需要处理日期选择器的更改事件。

  $('#trigger-datepicker').datepicker()
    .on("changeDate", function(e){
      $('#fechaTandas').prop('disabled',false);
      $('#fechaTandas').val(e.format('yyyy/mm/dd'));
      $('#fechaTandas').prop('disabled',true);
  });

演示:http://bootply.com/88516