Introduction


This post shows the code to validate a PAN number. Here is the Javascript code, just add the class "pan" in a text control.
PAN no. sample: ABCDE1234F
Code
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $(".pan").change(function () {
  4. var inputvalues = $(this).val();
  5. var regex = /[A-Z]{5}[0-9]{4}[A-Z]{1}$/;
  6. if(!regex.test(inputvalues)){
  7. $(".pan").val("");
  8. alert("invalid PAN no");
  9. return regex.test(inputvalues);
  10. }
  11. });
  12. });
  13. </script>
  14. PAN : <input type="text" class="pan">