Alphanumeric Validation Function

This script function will help you to validate a string / character for alphanumeric values.


  • The javascript function will return false when the string that is passed contains character other than alphanumeric.
  • It returns true on correct validation.
  • Just copy the code in to your page and use it.


Alpha numeric Testing :
Enter a character / string and test it
[ e.g: alfha or alp#num]


<!-- Script by -->
<script type="text/javascript">
function alphanumeric(alphane)
var numaric = alphane;
for(var j=0; j<numaric.length; j++)
var alphaa = numaric.charAt(j);
var hh = alphaa.charCodeAt(0);
if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
alert("Your Alpha Numeric Test Failed"); return false;
alert("Your Alpha Numeric Test Passed");
return true;
<!-- Script by -->

  • Release Date - 15-12-2004
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to


  • Here we have explained with a form
  • Creating the form using following HTML code
  • <form name="test" onSubmit="return alphanumeric(test.mailf.value)">
        <input name=mailf type=text>
        <input type=submit value=validate>      
  • The alphanumeric() function is triggered on submission of the form.
  • Just copy the javascript code and use it for free.


Related Scripts

Free Javascript Scripts

Ask Questions

Ask Question