How to verify PAN card?

前端 未结 15 1372
予麋鹿
予麋鹿 2021-02-13 11:46

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

相关标签:
15条回答
  • 2021-02-13 12:23

    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:

    • A — Association of persons (AOP)
    • B — Body of individuals (BOI)
    • C — Company
    • F — Firm
    • G — Government
    • H — HUF (Hindu undivided family)
    • L — Local authority
    • J — Artificial juridical person
    • P — Individual (proprietor)
    • T — Trust (AOP)
    • F – LLP (limited liability partnership)

    The fifth character of the PAN is the first character of either:

    • of the surname or last name of the person, in the case of a "personal" PAN card, where the fourth character is "P" or
    • of the name of the entity, trust, society, or organisation in the case of a company/HUF/firm/AOP/trust/BOI/local authority/artificial judicial person/government, where the fourth character is "C", "H", "F", "A", "T", "B", "L", "J", "G". The last (tenth) character is an alphabetic digit used as a check-sum to verify the
    0 讨论(0)
  • 2021-02-13 12:23

    pan card validation

    regex : /(^([a-zA-Z]{5})([0-9]{4})([a-zA-Z]{1})$)/

    0 讨论(0)
  • 2021-02-13 12:23

    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;
    }
    
    0 讨论(0)
  • 2021-02-13 12:24

    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

    0 讨论(0)
  • 2021-02-13 12:25
    ^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/
    

    Try This, hope will work

    0 讨论(0)
  • 2021-02-13 12:26

    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;
            }
        }
    
    0 讨论(0)
提交回复
热议问题