同一个css类上的日期选择器

时间:2017-03-08 10:39:10

标签: html css datepicker

我的主页有问题。可以使用以下数据创建事件:   - 开始  - 结束   - 说明

我在这段代码中使用bootstrap datepicker:

$('.form-control').datepicker({
      maxViewMode: 0,
      keyboardNavigation: false,
      forceParse: false,
      daysOfWeekDisabled: "0,6",
      daysOfWeekHighlighted: "0,6",
      todayHighlight: true,
      format: 'yyyy-mm-dd'
    });

这是我的HTML:

<!-- EndTime-->
  <div class="form-group">
    <label class="col-md-4 control-label">End</label>  
    <div class="col-md-4 inputGroupContainer">
    <div class="input-group">
    <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
    <input id="end" name="end" placeholder="Fill out!" class="form-control"  type="text">
      </div>
    </div>
  </div>

  <!-- Description -->
  <div class="form-group">
    <label class="col-md-4 control-label">Description</label>  
    <div class="col-md-4 inputGroupContainer">
    <div class="input-group">
    <span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
    <input id="description" name="description" class="form-control"  type="text">
      </div>
    </div>
  </div>

当然,日期选择器也会出现在说明字段中。我想避免这种情况,但我想保持&#34;表格控制&#34;类。

1 个答案:

答案 0 :(得分:4)

请试试这个..



    $('.form-control[name="end"]').datepicker({
    maxViewMode: 0,
    keyboardNavigation: false,
    forceParse: false,
    daysOfWeekDisabled: "0,6",
    daysOfWeekHighlighted: "0,6",
    todayHighlight: true,
    format: 'yyyy-mm-dd'
    });


https://jsfiddle.net/geogeorge/jk5udey2/2/