Sunday, May 3, 2015

Numeric operators only control handler

// Numeric operators only control handler
jQuery.fn.ForceNumericOnly =
        function () {
            return this.each(function () {
                $(this).keydown(function (e) {
                    var key = e.charCode || e.keyCode || 0;
                    var text = $(this).val();
                    // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
                    // home, end, period, and numpad decimal
                    if (e.shiftKey === true) {
                        return false;
                    }
                    if (key == 190 || key == 110) {
                        if (text.indexOf(".") >= 0) {
                            return false;
                        }
                    }
                    return (
                        key == 8 ||
                        //key == 16 ||
                        key == 9 ||
                        key == 46 ||
                        key == 110 ||
                        key == 190 ||
                        (key >= 35 && key <= 40) ||
                        (key >= 48 && key <= 57) ||
                        (key >= 96 && key <= 105));
                });
            });
        };

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...