2016-04-07 19 views
0

のためのテキスト入力フィールドを許可する。これは、日付ピッカーにフィールドdestinateを生成するために私のコードのHTMLです:日付ピッカー

<div class="col-md-12"> 
    <div class="form-group"> 
     <label class="form-font input-size"> Date:</label> 
     <div class="input-group"> 
      <input id="date-picker-2" type="text" class="date-picker form-control input-borders" name="pdf_date"/> 
      <label for="date-picker-2" class="input-borders input-group-addon btn"> 
       <span class="glyphicon glyphicon-calendar"></span> 
      </label> 
     </div> 
    </div> 

そして、これは、日付ピッカーを表示するには、私のJSコードです。

$(".date-picker").datepicker({ 
    format: "dd MM yyyy" 
}); 

テキストフィールドを入力する方法をお探しの場合は、選択した日付、特にテキストが表示されます。

ただし、日付を選択すると、テキスト入力は常に消えます。

これを避ける方法はありますか?

datepickerを表示するフィールドをクリックしてイベントを生成し、append属性(テキスト)を使用してhtmlに追加できますか?

少し基本的な質問かもしれませんが、解決できませんでした。

答えて

0
<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> 
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> 
</head> 
<body> 
    Shown Field : <input id="thedate" type="text" placeholder="dd MM yyyy" /><br /> 
    <input id="thesubmit" type="button" value="Submit" /> 
<script type="text/javascript"> 
    $(function(){ 
    $('#thedate').datepicker({ 
     dateFormat: 'dd-mm-yy', 
     altField: '#thealtdate' 
    }); 
    }); 
    </script> 
</body> 
</html>