Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SathishSaminathan/e3c509243ead20fcae26c87fdd6f78fd to your computer and use it in GitHub Desktop.
Save SathishSaminathan/e3c509243ead20fcae26c87fdd6f78fd to your computer and use it in GitHub Desktop.
Allow only the Alphabets inside the Textbox javascript (Exception:BackSpace),allow only alphabets inside textbox,how to validate textbox to accept only characters,allowing only alphabets in text box using java script
<html>
<head>
<script>
function myf(e)
{
var c=((e.which>=65 && e.which<91)||(e.which==8))
{
document.getElementById("error").style.display=c?"none":"inline"
}
return c;
}
</script>
</head>
<body>
<input type="text" id="txt" onkeydown="return myf(event)"><span id="error" style="color:red;display:none">Plese Enter Only Alphabets...</span>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment