Click here to Skip to main content
14,452,963 members
Rate this:
Please Sign up or sign in to vote.
See more:
<script>
$("#a").keypress(function(e) {
    if(e.which < 97 /* a */ || e.which > 122 /* z */) {
      /*  e.preventDefault(); */
        e.preventDefault();
        alert('Please enter only alphabate');
    }
});
</script>
Name:<input id="a" type="text" />



if user enter alphanumeric key then alert show inline validation (Name) input form.
Only allow alphabatic key in input form.
Posted
Updated 30-May-14 7:00am
v3
Comments
   
So, what is the issue?
amanpavanker 30-May-14 12:18pm
   
Only allow alphabatic key in input form.if user enter alphanumeric key then alert show inline validation (Name) input form.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").keypress(function (e) {
        if (!(e.which >= 65 && e.which <= 90) && !(e.which >= 97 && e.which <=122))   {

            alert(String.fromCharCode(e.keyCode | e.charCode));

        }

    });

});

</script>
</head>
<body>
<input style="width: 100px">
</body>
</html>
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100