How to verify PAN card?

前端 未结 15 1424
予麋鹿
予麋鹿 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条回答
  •  -上瘾入骨i
    2021-02-13 12:22

    Try this one

    $(document).ready(function() {
      $.validator.addMethod("pan", function(value1, element1) {
        var pan_value = value1.toUpperCase();
        var reg = /^[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[pan_value[3]];
    
        if (this.optional(element1)) {
          return true;
        }
        if (pan_value.match(reg)) {
          return true;
        } else {
          return false;
        }
    
      }, "Please specify a valid PAN Number");
    
      $('#myform').validate({ // initialize the plugin
        rules: {
          pan: {
            required: true,
            pan: true
          }
    
        },
        submitHandler: function(form) {
          alert('valid form submitted');
          return false;
        }
      });
    
    });
    
    
    
    
    

提交回复
热议问题