Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<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 6: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

Try this:
XML
<!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>
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900