i want to do pancard validation in javascript only.
Its limited to india only.
the structure of pancard in India is as follows.. for example : AAAAA9999A
Each deductee is uniquely identified by the PAN If the PAN does not follow the above structure, then the PAN will be shown invalid
The fourth character of the PAN must be one of the following, depending on the type of assessee:
The fifth character of the PAN is the first character in the surname of the person to whom the PAN belongs.
so i want of check first five letters are alphabetic then follow by four letter numeric and last one is alphabetic.
so i create javascript as follow.
var panVal = $('#panNumber').val);
var regpan = /^([a-zA-Z])([0-9])([a-zA-Z])?$/;
if(regpan.test(panVal)){
// valid pan card number
}else // invalid pan card number
but its not working for me.
help is more appreciated for me.
Thank in advance.
Step 1: Go to e-Filing portal homepage. Step 2: Click Verify Your PAN on the e-Filing homepage. Step 3: On the Verify Your PAN page, enter your PAN, Full Name, Date of Birth and Mobile Number (accessible to you) and click Continue.
PAN is a ten-digit unique alphanumeric number issued by the Income Tax Department. PAN is issued in the form of a laminated plastic card (commonly known as PAN card). Out of the first five characters, the first three characters represent the alphabetic series running from AAA to ZZZ.
There is a logical error in your code. Try the below code:
var panVal = $('#panNumber').val();
var regpan = /^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/;
if(regpan.test(panVal)){
// valid pan card number
} else {
// invalid pan card number
}
You have to limit the characters for how many time they have to occur in the given string.
Explanation
([a-zA-Z]){5} -> Alphabets should be 5 in number.
([0-9]){4} -> Numbers should be 4 in number.
([a-zA-Z]){1} -> Alphabets should be 1 in number.
Try this code it also tells about card type as asked by @RJParikh
function pan(txt)
{
txt = txt.toUpperCase();
var regex = /[a-zA-Z]{3}[PCHFATBLJG]{1}[a-zA-Z]{1}[0-9]{4}[a-zA-Z]{1}$/;
var pan = {C:"Company", P:"Personal", 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:"Govt"};
pan=pan[txt[3]];
if(regex.test(txt))
{
if(pan!="undefined")
alert(pan+" card detected");
else
alert("Unknown card");
}
else
alert("Unknown card");
}
<input id="pan">
<button onclick="pan(document.getElementById('pan').value)">search</button>
Hope it works well... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With