views:

18

answers:

1

I am trying to add the jQueryUI datepicker on a certain group of datefields, but exclude fields whose id ends in -0

Here is my code:

$(function() {
            $("input[id^='TOEFLtestDate-']").not([id$='-0']).datepicker({
                onClose: function(dateText, inst){
                    GenericDateUpdate(this.id, dateText,1);
                }
            });
        });

This code selects the correct pool of inputs:

$(function() {
            $("input[id^='TOEFLtestDate-']").datepicker({
                onClose: function(dateText, inst){
                    GenericDateUpdate(this.id, dateText,1);
                }
            });
        });

I just can't seem to get the filtering right to filter out the ids that end in -0.

Thanks for any help.

+3  A: 

You just need quotes in your first attempt, like this:

$("input[id^='TOEFLtestDate-']").not("[id$='-0']")

Or a bit cleaner, use the :not() selector, like this:

 $("input[id^='TOEFLtestDate-']:not([id$='-0'])")
Nick Craver
Thanks Nick... you must LIVE on StackOverflow. :-)
resonantmedia
@resonantmedia - Actually I'm building some materialized views at the moment, just answering in-between performance tests :)
Nick Craver