1

我正在使用bootstrap 3.0和bootstrap-datepicker從eternicode現在正在這個輸入。從eternicode bootstrap datepicker不選擇日期

問題是,我默認情況下輸入被禁用,因爲我不希望用戶通過他的手修改日期。

我正在分配一個帶日曆圖形的輸入插件來顯示日期選擇器。但問題是,無論何時我選擇日期,輸入都不會收到日期。我一直在閱讀文檔,並且有辦法做到這一點,但它僅適用於Bootstrap 2.3.2。

這是我的代碼,有誰知道我怎麼能從datepicker中選擇的日期轉移到我禁用的輸入?

幫助將非常感謝!

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"  
}); 

這是eternicodes日期選擇器插件的鏈接:

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

回答

1

我想你需要處理的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

+0

非常感謝您!它按預期工作。我不知道爲什麼這個語言不會變成西班牙語,因爲這個客戶是西班牙語的公司,但我必須稍後再看。 – codeninja

相關問題