﻿$.fn.focusOnSight = function () {
    this.focus();
    return this;
}

$.fn.jumpToNext = function (o) {
    var current_value = 0;

    var settings = $.extend({
        jump_at_length: 2,
        jump_to: ''
    }, o);

    $(this).focus(function (e) {
        current_value = this.value;
    });
    $(this).keyup(function (e) {
        if (this.value != current_value) {
            this.value > settings.jump_at_length
                ? this.value = this.value.substring(0, settings.jump_at_length)
                : '';
            this.value.length == settings.jump_at_length
                ? $(settings.jump_to).focus()
                : '';
        }

    });

    return this;
}
