validation for alpha in javascript

 <input type="text" class="text" placeholder="Name"  name="Name" id="Name" onkeypress="return alpha(event);"  >



.js
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
     <title>Letters ONLY</title>
<script type="text/javascript">
<!--
function alpha(e) {
     var k;
     document.all ? k = e.keyCode : k = e.which;
     return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8);
}
// -->
</script>
</head>
<body>
     <div>
          <form id="example" action="javascript://">
               <input type="text" onkeypress="return alpha(event)" />
          </form>
     </div>
</body>
</html>

No comments