I'm trying to disallow the up and down arrow key press on the text area of the combo (to ensure users do not accidentally select a different item) and used the following example provided in:
http://www.telerik.com/help/aspnet-ajax/combo-prevent-typing-particular-characters.html.
i am using firebug to step through the problem, the event fires however, the keypress is not disallowed.
I reverted back to example and noticed the example does not work too.
Please advise or post a working example.
<script type="text/javascript">
function pageLoad() {
var combo = $find("<%= RadComboBox1.ClientID %>");
var input = combo.get_inputDomElement();
input.onkeydown = onKeyDownHandler;
}
function onKeyDownHandler(e) {
if (!e)
e = window.event;
var code = e.keyCode;
//do not allow any of these chars to be entered: !@#$%^&*()
//if (e.shiftKey && code >= 48 && code <= 57){
if (code >= 39 && code <= 40) {
e.returnValue = false;
if (e.preventDefault) {
e.preventDefault();
}
}
}
</script>
<telerik:RadComboBox runat="server" ID="RadComboBox1" Height="400px"
Width="100%" AllowCustomText="True"
ShowMoreResultsBox="True"
EnableVirtualScrolling="True"
EnableLoadOnDemand="True"
HighlightTemplatedItems="true"
EnableItemCaching ="true"
onitemsrequested="RadComboBox1_ItemsRequested"
onclientselectedindexchanged= "AllowSelectionChanged"
onclientselectedindexchanging = "AllowSelectionChange"
OnClientItemsRequesting="OnClientItemsRequesting"
OnClientTextChange = "ValidateChange" Font-Size="X-Small"
ShowDropDownOnTextboxClick="False">
http://www.telerik.com/help/aspnet-ajax/combo-prevent-typing-particular-characters.html.
i am using firebug to step through the problem, the event fires however, the keypress is not disallowed.
I reverted back to example and noticed the example does not work too.
Please advise or post a working example.
<script type="text/javascript">
function pageLoad() {
var combo = $find("<%= RadComboBox1.ClientID %>");
var input = combo.get_inputDomElement();
input.onkeydown = onKeyDownHandler;
}
function onKeyDownHandler(e) {
if (!e)
e = window.event;
var code = e.keyCode;
//do not allow any of these chars to be entered: !@#$%^&*()
//if (e.shiftKey && code >= 48 && code <= 57){
if (code >= 39 && code <= 40) {
e.returnValue = false;
if (e.preventDefault) {
e.preventDefault();
}
}
}
</script>
<telerik:RadComboBox runat="server" ID="RadComboBox1" Height="400px"
Width="100%" AllowCustomText="True"
ShowMoreResultsBox="True"
EnableVirtualScrolling="True"
EnableLoadOnDemand="True"
HighlightTemplatedItems="true"
EnableItemCaching ="true"
onitemsrequested="RadComboBox1_ItemsRequested"
onclientselectedindexchanged= "AllowSelectionChanged"
onclientselectedindexchanging = "AllowSelectionChange"
OnClientItemsRequesting="OnClientItemsRequesting"
OnClientTextChange = "ValidateChange" Font-Size="X-Small"
ShowDropDownOnTextboxClick="False">