Custom key press validation

3 posts, 0 answers
  1. Clinton Smyth
    Clinton Smyth avatar
    71 posts
    Member since:
    Apr 2007

    Posted 19 Aug 2010 Link to this post

    Hi

    I have a javascript function that validates client input as they're typing.  If the user types an invalid character, the function (decOnlyKey below) returns false.

    function RadComboBoxKeyPressing(combo, eventArgs) {
        var key = eventArgs.get_domEvent().keyCode;
        var allow = decOnlyKey(key, combo.get_text());
     
    //    if (!allow)
    //        eventArgs.set_cancel(true);
    }

    It appears this eventArgs object does not have a set_cancel method (hence commented out above).

    How can I get the RadComboBox to reject the key press?

    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2010 Link to this post

    Hello Clinton,

    A better option would be attaching onkeydown event to combo input textbox from client side and canceling the event based on condition. More information on this can be found here.
    Prevent user from typing particular characters


    -Shinu.
  3. Clinton Smyth
    Clinton Smyth avatar
    71 posts
    Member since:
    Apr 2007

    Posted 24 Aug 2010 Link to this post

    Thanks - that did the trick!
Back to Top