Allow only alphabets for textbox

by Nirmala 2010-04-08 17:50:32

Allow only alphabets
Use the below code to allow only alphabets in your textbox.
<html>
<head>
<script type = "text/javascript">
function AllowAlphabet(){
if (!TEST.TESTER.value.match(/^[a-zA-Z]+$/) && TEST.TESTER.value !="")
{
TEST.TESTER.value="";
TEST.TESTER.focus();
alert("Please Enter only alphabets in text");
}
}

</script>
</head>
<body>
<form name="TEST">
<input type="text" name="TESTER" onkeyup="AllowAlphabet()">
</form>
</body>
</html>

Tagged in:

6958
like
1
dislike
0
mail
flag

You must LOGIN to add comments