0

我正在使用此日期選擇器。
http://bootstrap-datepicker.readthedocs.org/en/release/引導日期選擇器禁用並啓用條件

我的問題是,我想在某些情況下啓用日期選擇器。 例如:我有一個國家的選擇框,如果國家是美國,我想啓用日期選擇器,否則禁用它。禁用日期選擇器意味着用戶不能選擇日期或不彈出日期選擇器。 我選擇日期選擇器日期選擇器日曆圖標不與教科書。

回答

0

我假設你使用jQuery和你的國家選擇框是帶班的「國家」,那麼這樣的事情應該爲你工作:

$(document).ready(function(){ 
    $(".country").change(function(e){ 
    var country = $(".country").val(); //get the value of the country select 
    if (country != "US") { // you probably use some id and not the country name as value 
     $(".datepicker").datepicker("remove"); // remove the datepicker 
    } 
    }); 
}); 
+0

感謝它爲我工作。 – 2014-11-05 18:53:04

+0

@ankitmaini如果這是爲你工作,你應該選擇這個答案? – ndyakov 2014-11-06 08:38:57

+0

我想這樣做,但我不知道該怎麼做 – 2014-11-06 08:42:40

相關問題