allow only Alphabets using JQuery

Leave a Comment
Hi All

This is code ,will allow only Alphabets in TextBox.


$('#<%=txtDescription.ClientID %>').live("keypress", function (e) {
        var key = (e.keyCode ? e.keyCode : e.which);
        if ((key == 8) || (key == 46) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || (key == 32) || (key == 9)) {

        } else { e.preventDefault(); }
    });

For more clarification regarding the ascii codes refer http://www.asciitable.com/

Related Post

0 comments:

Post a Comment