简体   繁体   English

在jQuery UI Datepicker的输入中显示完整日期

[英]Show full date in input for jQuery UI Datepicker

Using jQuery UI datepicker, I have the following: 使用jQuery UI datepicker,我有以下内容:

<input type="text" id="check_in">

$( "#check_in" ).datepicker({
  numberOfMonths: 2,
  dateFormat: 'dd/mm/yy',
  minDate: -1
});

When a date is chosen, the date is shown in the input field as 31/12/2013 . 选择日期后,该日期在input字段中显示为31/12/2013 How can I make it show "31 December 2013" in the input field, but upon submission it is still 31/12/2013 ? 我怎样才能使它在显示“2013年12月31” input字段,但是在提交它仍然是31/12/2013

You'll need two inputs: 您将需要两个输入:

<input type="text" id="check_in" />
<input type="hidden" id="altfield" name="date" />

and to change the JS to 并将JS更改为

$("#check_in").datepicker({
    numberOfMonths: 2,
    altField: '#altfield',
    altFormat: 'dd/mm/yy',
    dateFormat: 'dd MM yy',
    minDate: -1
});

FIDDLE 小提琴

The hidden input will be submitted with the dd/mm/yy value, while the visible input will show the format you're trying to show. 隐藏的输入将使用dd/mm/yy值提交,而可见的输入将显示您尝试显示的格式。

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

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