简体   繁体   English

如何显示仅年度日历?

[英]How to Display year only Calendar?

I am using Predefined bootstrap calendar in my page. 我在页面中使用预定义的引导日历。 Its working Properly, but for few text box I need to display year only calendar. 它的工作正常,但对于很少的文本框,我只需要显示年份日历。

My Codes are 我的密码是

<!-- bootstrap datepicker -->
    <link rel="stylesheet" href="~/Content/adminlte/components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">


 <!-- bootstrap datepicker -->
    <script src="~/Content/adminlte/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

 <script>
        $(function () {

            $('#Date').datepicker({
                autoclose: true
            })
        })</script>

Design 设计

  <label>Date</label>
  <div class="input-group date">
 <input type="text" class="form-control pull-right" id="Date">
 <div class="input-group-addon">
 <i class="fa fa-calendar"></i>
 </div>
 </div>

My datpicker with text box image as follows 我的带有文本框图像的datpicker如下

在此处输入图片说明

Its working fine to pickup a date. 它可以正常工作以约会。 But for few text box I need year only option as shown in image below 但是对于少数文本框,我需要仅年份选项,如下图所示

在此处输入图片说明

If I use code from some other stackoverflow answers or from this link code , it affect my date picker design and it also change the option for all text boxes to choose normal date also... Kindly help.. TIA. 如果我使用其他一些stackoverflow答案或此链接代码中的代码 ,则它会影响我的日期选择器设计,并且还更改所有文本框的选项以选择正常日期。.TIA。

use this config options : 使用此配置选项

$("#Date").datepicker({
    autoclose: true,
    format: "yyyy",
    viewMode: "years", 
    minViewMode: "years"
});

Look if you go to jquery page and searched for calender. 查看您是否转到jquery页面并搜索日历。 They will tell you the properties for calender format and how to use them and thus you copy and paste thrm in your bootstrap calender since it will be the same. 他们会告诉您压光机格式的属性以及如何使用它们,因此您将thrm复制并粘贴到自举压光机中,因为它是相同的。 Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM