How to check the validation of edittext for pan card like \"ABCDE1234F\". I am confused how to check the the validation for this. Please help me guys. I will appreciate any kind
This is perfect PAN number RegEx: :
String panNumber = "AAAPL1234C"; // get your editext value here
Pattern pattern = Pattern.compile("[A-Z]{3}[ABCFGHLJPTF]{1}[A-Z]{1}[0-9]{4}[A-Z]{1}");
Matcher matcher = pattern.matcher(panNumber );
// Check if pattern matches
if (matcher.matches()) {
Log.i("Matching","Yes");
}
There are some condition for PAN number as follow :
The PAN (or PAN number) is a ten-character long alpha-numeric unique identifier.
The PAN structure is as follows: AAAPL1234C:
The first five characters are letters (in uppercase by default), followed by four numerals, and the last (tenth) character is a letter. The first three characters of the code are three letters forming a sequence of alphabets letters from AAA to ZZZ
The fourth character identifies the type of holder of the card. Each holder type is uniquely defined by a letter from the list below:
The fifth character of the PAN is the first character of either:
pan card validation
regex : /(^([a-zA-Z]{5})([0-9]{4})([a-zA-Z]{1})$)/
Note that none of other answers available so far doesn't verify PAN check digit.
Here is Luhn algorythm from http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Java:
public static boolean luhnTest(String number) {
int s1 = 0, s2 = 0;
String reverse = new StringBuffer(number).reverse().toString();
for (int i = 0 ; i < reverse.length(); i++){
int digit = Character.digit(reverse.charAt(i), 10);
if (i % 2 == 0) { //this is for odd digits, they are 1-indexed in the algorithm
s1 += digit;
} else { //add 2 * digit for 0-4, add 2 * digit - 9 for 5-9
s2 += 2 * digit;
if (digit >= 5) {
s2 -= 9;
}
}
}
return (s1 + s2) % 10 == 0;
}
Hi for pan card verification you need to execute two step process in your project.
1.) create a form and get user pan card number
2.) upload user pan card image
After complete both step make a logic in backend for verification. For this you can follow below tutorial:
https://www.lelocode.com/posts/pan-verification-in-laravel-using-baidu-ocr-universal-text-recognition-%28high-precision-version%29
^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/
Try This, hope will work
You can use Key press Event for PAN Card Validation in C#
enter code here
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
int sLength = textBox1.SelectionStart;
switch (sLength)
{
case 0:
case 1:
case 2:
case 3:
case 4:
if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
case 5:
case 6:
case 7:
case 8:
if (char.IsNumber(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
case 9:
if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
break;
default:
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
}
}