0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

bootstrap-datepickerをimportして使う

Posted at

importが理解できてないんのもあって、npmインストールした後どう使うのかなと思ったら以下で動いたのでメモしておきます。

import 'bootstrap-datepicker';
import 'bootstrap-datepicker/dist/locales/bootstrap-datepicker.ja.min.js'

Typescriptで使うため以下もインストール。

@types/bootstrap-datepicker 

下記でdateタイプのテキストボックスに適用しました。

$('input[type="date"]').datepicker({
        format:'yyyy-mm-dd',
        language:'ja',
        beforeShowDay: (date)=>{

            const custumdate = {classes:''}

            switch(date.getDay()){
                case 0: //Sun
                    custumdate.classes = 'sunday';
                    break;
                case 6: //Sat
                    custumdate.classes = 'saturday';
                    break;
            }
            
            return custumdate;
        }
    });

HTML5のカレンダーアイコンを以下のCSSで非表示に

input[type="date"]::-webkit-calendar-picker-indicator { 
  display: none; 
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?