﻿//M.FATİH KOÇAK 19.08.2010
(function ($) {

    $.fn.Numeric = function (Settings) {
        var NumericChar = "1234567890";
        Settings = $.extend({ AllowChar: null }, Settings);
        if (Settings.AllowChar != null) {
            NumericChar += Settings.AllowChar;
        }
        $(this).keypress(function (e) {

            if (!e.charCode) k = String.fromCharCode(e.which);
            else k = String.fromCharCode(e.charCode);
            if (e.charCode != 0)
                if (NumericChar.indexOf(k) == -1) e.preventDefault();

        });
    }

    $.fn.Alpha = function (Settings) {
        Settings = $.extend({ Turkish: false, AllowChar: null }, Settings);

        var EnglishChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        EnglishChar += "abcdefghijklmnopqrstuvwxyz";
        if (Settings.Turkish == true) {
            EnglishChar += "çğöüşÇĞİÖÜŞ";
        }
        if (Settings.AllowChar != null) {
            EnglishChar += Settings.AllowChar;
        }

        $(this).keypress(function (e) {
            if (!e.charCode) k = String.fromCharCode(e.which);
            else k = String.fromCharCode(e.charCode);
            if (e.charCode != 0)
                if (EnglishChar.indexOf(k) == -1) e.preventDefault();
        });
    }

    $.fn.AllowList = function (Settings) {
        Settings = $.extend({ AllowChar: null }, Settings);
        var Allowlist = '';
        if (Settings.AllowChar != null)
            Allowlist = Settings.AllowChar;

        $(this).keypress(function (e) {
            if (!e.charCode) k = String.fromCharCode(e.which);
            else k = String.fromCharCode(e.charCode);
            if (e.charCode != 0)
                if (Allowlist.indexOf(k) == -1) e.preventDefault();
        });

    }

    $.fn.Lock = function () {

        $(this).keypress(function (e) {
            e.preventDefault();
        });

    }


} (jQuery));
