CancelImage Upload

How to validate India's Permanent Account Number using Regular Expressions

The Permanent Account Number (PAN) is India's equivalent of a National Identification Number. It is a 10 Symbol code that is issued to all taxpayers by the Indian Income Tax Department. It is a standard requirement for opening bank accounts, the instalment of a personal phone line, and receiving a salary. Naturally it's main purpose is to help prevent tax evasion.

Now before we can write a regular expression to validate the Permanent Account Number, we need to have a closer look at its format. Here is an example:


So, the first 5 characters have to be letters, followed by four numbers, and then another letter. The fourth character usually describes the cardholder:

C = Company
P = Person
H = Hindu Undivided Family (HUF)
F = Firm
A = Association of Persons (AOP)
T = AOP (Trust)
B = Body of Individuals (BOI)
L = Local Authority
J = Artificial Juridical Person
G = Goverment

We will now move on to the regular expression that can be used to validate this above code. Note that we will not build in a check for the above cardholder descriptions, as a new one could join the list at any point in time, and render our regular expression obsolete. The format itself though should not change anytime soon:


For a more extensive example of try the JavaScript valuator below:

<title>Permanent Account Number Code Validation with JavaScript</title>

<script language="JavaScript">

function pan_validate(pan)

var regpan = /^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/;

if(regpan.test(pan) == false)

document.getElementById("status").innerHTML = "Permanent Account Number is not yet valid.";


document.getElementById("status").innerHTML = "You have entered a valid Permanent Account Number !";



<style type="text/css">
body {

div {
width: 100%;
text-align: center;

span {
color: #000099;
font: 8pt verdana;

input {
color: #000000;
background: #F8F8F8;
border: 1px solid #353535;
font: 8pt verdana;

<span id="status">Please enter a valid Permanent Account Number.</span><br>
<input type="text" name="pan" onkeyup="pan_validate(this.value);">


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •