views:

75

answers:

1

I have the jQuery datepicker working, but I need to be able to select more than just dates. I need to be able to select between some strings as well "Yesterday" and "Today" to be precise. So, the underlying input can contain any date as well as the strings "Yesterday" or "Today".

Is there some way I can do this by tweaking the existing jQuery UI datepicker?

A: 

Ultimately, I resorted to just capturing when they click, and if they select Today or Yesterday, putting the word in rather than the actual date.

$('.DatePicker').datepicker({
    showOn: 'button',
    buttonImage: 'images/cal/cal.jpg',
    buttonImageOnly: true,
    changeMonth: true,
    changeYear: true,
    onSelect: function(dateText, inst) {
        var $this = $(this);
        var selected = new Date($this.val());
        var today = new Date();         
        var yesterday = new Date();             
        yesterday.setDate(today.getDate() - 1);

        if (today.toDateString() == selected.toDateString()) {// TODAY
            $this.val('Today');
        } else if (yesterday.toDateString() == selected.toDateString()) {// YESTERDAY
            $this.val('Yesterday');
        }
    }
});

I would have preferred to add a couple buttons to the bottom of the control, but... this will do.

Chad