This is a migrated thread and some comments may be shown as answers.

Custom key press validation

2 Answers 51 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Clinton Smyth
Top achievements
Rank 1
Clinton Smyth asked on 20 Aug 2010, 12:39 AM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Aug 2010, 05:36 AM
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.
0
Clinton Smyth
Top achievements
Rank 1
answered on 24 Aug 2010, 06:43 PM
Thanks - that did the trick!
Tags
ComboBox
Asked by
Clinton Smyth
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Clinton Smyth
Top achievements
Rank 1
Share this question
or