altFormat在jQuery datepicker输入字段中不起作用 [英] altFormat not working in jQuery datepicker input field
问题描述
我有日期字段(id开始日期)
I have date field (id begin-date)
$( "#begin-date" ).datepicker({
minDate: -20,
maxDate: "+1M +10D",
dateFormat: "yy-mm-dd",
altFormat: "yymmdd"
});
在发布时,它会打印格式为yy-mm-dd(2010-12-08)什么时候打印为yymmdd(20101208)
On post, it prints the format as yy-mm-dd (2010-12-08), when it should print as yymmdd (20101208)
任何想法,为什么它不能正常发布与altFormat设置?
Any ideas of why it is not posting it properly with altFormat set?
输入字段渲染:
<input type="text" name="begin_date" id="begin-date" class="validate[required]" value="" />
推荐答案
altFormat
选项不使用日期选择器控制输入的格式,而是由 altField
选项,如下所示:
The altFormat
option doesn't control the formatting of the input with the date picker, but the format of an alternate (usually hidden) field specified by the altField
option, like this:
$("#begin-date").datepicker({
minDate: -20,
maxDate: "+1M +10D",
dateFormat: "yy-mm-dd",
altFormat: "yymmdd",
altField: "#alt-date"
});
你可以在这里测试;你可能想要的是将名称
放在该alt字段上,这将是什么会发布...没有一个名称
具有日期选择器的字段将不会被序列化/提交,例如:
You can test it out here; what you probably want is to just put the name
on that alt field and that's what'll get posted...without a name
the field with the date picker won't get serialized/submitted, for example:
<input type="text" id="begin-date" class="validate[required]" />
<input type="text" id="alt-date" name="begin_date" />
这篇关于altFormat在jQuery datepicker输入字段中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!