Monday, August 18, 2014

Allow only alphabets in textbox using jquery

Allow only alphabets in textbox using jquery



Need library file to perform this action.Please copy and Paste below library file.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>


jQuery Function

<script type="text/javascript">
        $(function () {
            $('#txtvalue').keydown(function (e) {
                        if (e.shiftKey || e.ctrlKey || e.altKey) {
                        e.preventDefault();
                    } else {
                        var key = e.keyCode;
                        if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
                        e.preventDefault();
                    }
                }
            });
        });
        </script>

HTML

Enter Your Text:<input type="text" id="txtvalue" />

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

No comments:

Post a Comment