locked
how to disable enter key in textbox using javascript Visual Studio 2012

    Question

  • <input id="inputInput" class="inputInput" type="text"/> 

     
    Monday, February 4, 2013 10:08 PM

Answers

  • function stopRKey(evt) {
            var evt = (evt) ? evt : ((event) ? event : null);
    
            var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
            if ((evt.keyCode == 13) && (node.type == "text")) {
                return false;
            }
        }

    document.onkeypress = stopRKey;

    • Marked as answer by Milan LLC Tuesday, February 5, 2013 12:40 AM
    Tuesday, February 5, 2013 12:40 AM