Exemplo n.º 1
0
 void DisableNonNumericValues(jQueryKeyboardEvent e)
 {
     if (e.Which != 8 && e.Which != 0 && (e.Which < 48 || e.Which > 57))
     {
         e.PreventDefault();
     }
 }
Exemplo n.º 2
0
        void OnKeyPress(jQueryKeyboardEvent e)
        {
            KeyPress?.Invoke(e);

            if (AllowOnlyDecimalInputs)
            {
                DisableNonDecimalInputs(e);
                return;
            }

            if (AllowOnlyNumericInputs)
            {
                DisableNonNumericValues(e);
            }
        }
Exemplo n.º 3
0
        void DisableNonDecimalInputs(jQueryKeyboardEvent e)
        {
            var isDot = e.Which == 46;

            if (isDot)
            {
                var alreadyContainsDot = (_value + "").IndexOf('.') >= 0;
                if (alreadyContainsDot)
                {
                    e.PreventDefault();
                }

                return;
            }

            DisableNonNumericValues(e);
        }