Following is the code for the alphanumeric validation in JavaScript
Javascript | | copy code | | ? |
01 | <script type="text/javascript"> |
02 | function alphanumeric(abc) |
03 | { |
04 | var numaric = abc; |
05 | for(var j=0; j<numaric.length; j++) |
06 | { |
07 | var alphaa = numaric.charAt(j); |
08 | var hh = alphaa.charCodeAt(0); |
09 | if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123)) |
10 | { |
11 | } |
12 | else { |
13 | alert("value entered is not alphanumeric"); |
14 | return false; |
15 | } |
16 | } |
17 | return true; |
18 | } |
19 | </script> |
20 |