Jump to content

How Only number in TUniDbNumberEdit not '-' double -- is it possible?


Recommended Posts

Posted

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...

  • 1 year later...
Posted

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();}
}

  • 2 years later...
Posted

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();
    }
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...