jean_5 0 Light Poster

I already have a datepicker to get the start date and the final date, it already makes the validation when the user clicks only on the calendar, but when it's typed, it's not validated. So, i thought something like this:

datePickerRange: function () {

        if ($(this).length != 2) return;

        var dteIni = $(this)[0];
        var dteFrom = $(this)[1];

        var dates = $(this).datepicker({
            dateFormat: 'dd/mm/yy',
            changeMonth: true,
            numberOfMonths: 1,
            onSelect: function (selectedDate) {

                var option = this.id == dteIni.id ? "minDate" : "maxDate",
                    instance = $(this).data("datepicker"),
                    date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                        $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings);
                dates.not(this).datepicker("option", option, date);
            }
        })
        .change(function () {
            var dataInicial = $(this).data("datepicker");
            if (minDate > maxDate)
                alert("Data Inicial maior que a Final");
            if (maxDate < minDate)
                alert("Data Final manor que a Inicial");
        });
        ;
    },

But the change function does not return me nothing. How can i solve this situation?