Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

PAN Card Number Validation

5.00/5 (1 vote)
28 Nov 2012CPOL 61.4K  
Sample script for PAN card number validation.

PAN card number is a unique national number issued in India for tax related purposes.

To validate PAN card, call this line of code (JavaScript) on onblur like:

ASP.NET
<asp:TextBox ID="txtpancard"
   runat="server"  Width="190px" 
   onblur="fnValidatePAN(this);" >
</asp:TextBox>
JavaScript
<script type="text/javascript" language="javascript">
    function fnValidatePAN(Obj) {
        if (Obj == null) Obj = window.event.srcElement;
        if (Obj.value != "") {
            ObjVal = Obj.value;
            var panPat = /^([a-zA-Z]{5})(\d{4})([a-zA-Z]{1})$/;
            var code = /([C,P,H,F,A,T,B,L,J,G])/;
            var code_chk = ObjVal.substring(3,4);
            if (ObjVal.search(panPat) == -1) {
                alert("Invalid Pan No");
                Obj.focus();
                return false;
            }
            if (code.test(code_chk) == false) {
                alert("Invaild PAN Card No.");
                return false;
            }
        }
   }
</script>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)