altFormat 在 jQuery 日期选择器输入字段中不起作用 [英] altFormat not working in jQuery datepicker input field
问题描述
我有日期字段 (id begin-date)
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"
});
你可以在这里测试;您可能想要的只是将 name
放在该 alt 字段上,这就是将要发布的内容...如果没有 name
,带有日期选择器的字段将不会获得序列化/提交,例如:
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 日期选择器输入字段中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!