altFormat not working in jQuery datepicker input field

≯℡__Kan透↙ 提交于 2019-11-30 11:20:00

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"
});

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" />

the altFormat must work with altField;

<input type="text" name="pushTime" class="datetime" id="pushTime"/> $(".datetime").datepicker({altFormat:"yy-mm-dd",altField: "#pushTime"});

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!