jquery:使用两个日期选择器两个字段(字段1,字段2 + 1天),如booking.com [英] jquery: using two datepicker with two fields ( field 1 , field2 + 1 day ) like booking.com
本文介绍了jquery:使用两个日期选择器两个字段(字段1,字段2 + 1天),如booking.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何ru?
我有两个带两个字段的日期选择器
我想当用户选择(From)第二个字段(TO)将在第二天。例如 booking.com
例如:当用户选择从 01-01-2013时, ... 看看这张图片
这是jquery的代码:
$(function (){
$(#from).datepicker({
defaultDate:+ 1D,
changeMonth:true,
numberOfMonths:1,
dateFormat :dd-mm-yy,
minDate:+ 1D,
showOn:button,
buttonImage:http://keith-wood.name/img/calendar (dateText + 1),DD / MM,
/ YYYY);
$(#to).val(d);
}
});
这是我的html代码:
< form method =getaction =>
< input type =submitvalue =choose/>
< p>< input type =textname =fromid =from/> From< br />
< input type =textname =toid =to/> To
< / p>
< / br>
< / form>
怎么办?
解决方案
onSelect:function(dateText,inst){
var d = $。 datepicker.parseDate(inst.settings.dateFormat,dateText);
d.setDate(d.getDate()+ 1);
$(#to)。val($。datepicker.formatDate(inst.settings.dateFormat,d));
}
How r u?
I have two datepickers with two fields
I want when the user choosing (From) the second field ( TO ) will be next day . like booking.com
for example: when the user choose From 01-01-2013 , directly the second field TO 02-01-2013 (next day) ...
look at this picture for the form
this is code of jquery:
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1D",
changeMonth: true,
numberOfMonths: 1,
dateFormat:"dd-mm-yy",
minDate: "+1D",
showOn: "button",
buttonImage: "http://keith-wood.name/img/calendar.gif",
buttonImageOnly: true ,
onSelect: function(dateText, inst){
var d = dateFormat(new Date(dateText + 1), "DD/MM/YYYY");
$("#to").val(d);
}
});
this is my html code:
<form method="get" action="">
<input type="submit" value="choose"/>
<p><input type="text" name="from" id="from" />From<br/>
<input type="text" name="to" id="to" />To
</p>
</br>
</form>
how can do it?
解决方案
onSelect: function(dateText, inst){
var d = $.datepicker.parseDate(inst.settings.dateFormat, dateText);
d.setDate(d.getDate()+1);
$("#to").val($.datepicker.formatDate(inst.settings.dateFormat, d));
}
这篇关于jquery:使用两个日期选择器两个字段(字段1,字段2 + 1天),如booking.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文