alphabet only in jquery 1

alphabet only in jquery

            $( document ).ready(function() {
                $( ".txtOnly" ).keypress(function(e) {
                    var key = e.keyCode;
                    if (key >= 48 && key <= 57) {  // 0-9
                        e.preventDefault();
                    }
                });
            });

Here is what the above code is Doing:
1. It's creating a function called "txtOnly"
2. It's telling the function to only allow letters to be typed in the input field
3. It's telling the function to not allow numbers to be typed in the input field
4. It's telling the function to not allow special characters to be typed in the input field
5. It's telling the function to not allow spaces to be typed in the input field

Similar Posts