Showing posts with label PAN no. Show all posts
Showing posts with label PAN no. Show all posts

Tuesday, 7 January 2020

PAN no validation using javascript or jquery

Introduction  

Here is a javascript code to validate PAN no.

PAN no sample : ABCDE1234F

Code


  1. <script type="text/javascript">  
  2. $(document).ready(function(){   
  3.       
  4. $(".pan").change(function () {    
  5. var inputvalues = $(this).val();    
  6.   var regex = /[A-Z]{5}[0-9]{4}[A-Z]{1}$/;  
  7.   if(!regex.test(inputvalues)){    
  8.   $(".pan").val("");  
  9.   alert("invalid PAN no");  
  10.   return regex.test(inputvalues);  
  11.   }  
  12. });    
  13.   
  14. });  
  15. </script>  
  16.   
  17. PAN : <input type="text" class="pan">