altFormat在jQuery datepicker输入字段中不起作用 [英] altFormat not working in jQuery datepicker input field

查看:225
本文介绍了altFormat在jQuery datepicker输入字段中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有日期字段(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆