﻿jQuery.fn.autoFormat = function (options, callback) {

    var ctl = $(this);
    defOptions = jQuery.extend({
        dataType: "date",
        useNextDate: false
    }, options);

    ctl.change(function () {
        $.get("handlers/autoformat.ashx?text=" + ctl.val() + "&mode=" + defOptions.dataType,
                    function (data) {
                        ctl.val(data);
                        if (typeof callback == 'function') {
                            callback.call(this, data);
                        }
                    });
    });

}
