Ulugbek Posted September 29, 2013 Posted September 29, 2013 How Only number in TUniDbNumberEdit not '-' double -- is it possible? Only number not '-' or double '-''-' only absolute number how ? Quote
Sherzod Posted September 30, 2013 Posted September 30, 2013 Hi Ulugbek.try this: UniDBNumberEdit1 > ClientEvents > ExtEvents > OnKeydown function OnKeydown(sender, e) { var event = e; if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || (event.keyCode == 65 && event.ctrlKey === true) || (event.keyCode >= 35 && event.keyCode <= 39)) { return; } else { if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) { event.preventDefault(); } } } Javascript Char Codes (Key Codes) - http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes Best regards... Quote
Ulugbek Posted September 30, 2013 Author Posted September 30, 2013 Thank you will try Why This code not work onkeypress event if Key In ['-'] Then Key := #0; end; Quote
mxnoname Posted December 25, 2014 Posted December 25, 2014 function keydown(sender, e, eOpts){ if (e.keyCode != 8 && e.keyCode != 9 && e.keyCode != 45 && e.keyCode != 46 && e.keyCode != 33 && e.keyCode != 34 && e.keyCode != 35 && e.keyCode != 36 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40 && e.keyCode != 48 && e.keyCode != 49 && e.keyCode != 50 && e.keyCode != 51 && e.keyCode != 52 && e.keyCode != 53 && e.keyCode != 54 && e.keyCode != 55 && e.keyCode != 56 && e.keyCode != 57 && e.keyCode != 96 && e.keyCode != 97 && e.keyCode != 98 && e.keyCode != 99 && e.keyCode != 100 && e.keyCode != 101 && e.keyCode != 102 && e.keyCode != 103 && e.keyCode != 104 && e.keyCode != 105) {e.stopEvent();}} Quote
Administrators Farshad Mohajeri Posted December 25, 2014 Administrators Posted December 25, 2014 Thank you will try Why This code not work onkeypress event if Key In ['-'] Then Key := #0; end; This is a server side code which will not reflect client side. Quote
RobYost Posted October 5, 2017 Posted October 5, 2017 This allows integers only. function OnKeydown(sender, e) { var ok = event.keyCode == 8 || //backspace event.keyCode == 9 || //tab event.keyCode == 13 || //enter event.keyCode >= 35 && event.keyCode <= 37 || //end, home, left arrow event.keyCode == 39 || //right arrow, downd arrow, insert, delete event.keyCode == 45 || //insert event.keyCode == 46 || //delete event.keyCode >= 96 && event.keyCode <= 105 || // 0-9 on keypad event.keyCode >= 48 && event.keyCode <= 57; // 0-9 if (!ok) { e.preventDefault(); } } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.