Intersoft WebCombo Documentation
How-to: Validate string only input in OnKeyDown client side events
See Also Send comments on this topic.
Intersoft WebCombo > WebCombo Features Overview > Client-side Programming How-to Topics > How-to: Validate string only input in OnKeyDown client side events

Glossary Item Box

In order to validate string only input, you can use OnKeyDown Client-side event in WebCombo.

In this topic, you will learn how to implement the method.

To validate string only input Client-side event

  1. Drag a WebCombo instance into the WebForm.
  2. Add the following code in client side:

    JavaScript Copy ImageCopy Code
    function WebCombo1_OnKeyDown()
    {           
        var n ="";
        var e = window.event;
        
        if (48<=e.keyCode && e.keyCode<=57)
                n = e.keyCode - 48;
        else
                if (96<=e.keyCode && e.keyCode<=105)
                        n = e.keyCode - 96;
                else
                        if (e.keyCode==110 || e.keyCode==190)
                                n = "."; 
        if (n != "")
           return false;       
        else
           return true; 
    }
    

  3. Invoke WebCombo1_OnKeyDown() function in OnKeyDown client side event of WebCombo.
  4. Run the project.

See Also