void DisableNonNumericValues(jQueryKeyboardEvent e) { if (e.Which != 8 && e.Which != 0 && (e.Which < 48 || e.Which > 57)) { e.PreventDefault(); } }
void OnKeyPress(jQueryKeyboardEvent e) { KeyPress?.Invoke(e); if (AllowOnlyDecimalInputs) { DisableNonDecimalInputs(e); return; } if (AllowOnlyNumericInputs) { DisableNonNumericValues(e); } }
void DisableNonDecimalInputs(jQueryKeyboardEvent e) { var isDot = e.Which == 46; if (isDot) { var alreadyContainsDot = (_value + "").IndexOf('.') >= 0; if (alreadyContainsDot) { e.PreventDefault(); } return; } DisableNonNumericValues(e); }