Skip to content

Instantly share code, notes, and snippets.

@tj
Created June 9, 2009 19:27
Show Gist options
  • Save tj/126738 to your computer and use it in GitHub Desktop.
Save tj/126738 to your computer and use it in GitHub Desktop.
var update = function(id, prev) {
return function(dateText, date) {
$(id).val(dateText.replace(/\/(\d{1,2})\//, function(_, day){
return '/' + (prev ? --day : ++day) + '/'
}))
}
}
$("#datepicker1").datepicker({ onSelect : update('#datepicker2') })
$("#datepicker2").datepicker({ onSelect : update('#datepicker1', true) })
$(function() {
$("#datepicker1").datepicker({ showOn: 'button', buttonImage: '/sites/all/themes/hotelgrandpacific/img/calendar.png', buttonImageOnly: true })
$("#datepicker2").datepicker({ showOn: 'button', buttonImage: '/sites/all/themes/hotelgrandpacific/img/calendar.png', buttonImageOnly: true })
var update = function(id, prev) {
return function(dateText, date) {
$(id).val(dateText.replace(/\/(\d{1,2})\//, function(_, day){
return '/' + (prev ? --day : ++day) + '/'
}))
}
}
$("#datepicker1").datepicker({ onSelect : update('#datepicker2') })
$("#datepicker2").datepicker({ onSelect : update('#datepicker1', true) })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment