function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lavanya gottumukkalalavanya gottumukkala 

How to write validation rule for PANCARD number using REGEX function for a picklist field?

Hi All,

I have one picklist field with values like PAN,TAN,VAT,etc.....And I need to write a validation rule for the format of PAN number for that picklist field.Is it possible?
I have written the below formula but didn't work
NOT(REGEX(ISPICKVAL(PANCARD__c ,"((([a-zA-Z]{5})\\d{4})[a-zA-Z]{1})"))
Any one has any idea?It's urgent

Thanks in advance
Ravi Dutt SharmaRavi Dutt Sharma
So you have a picklist and a text field in which you will store the data. If in picklist value is PAN, then you will store PAN Card number in PANCARD__c text field? Is it?
N.V.V.L.Vinay KumarN.V.V.L.Vinay Kumar
Hi Lavanya,
Try below formula.

//In Place of piclistfield use the api name of the picklist field containing PAN,TAN,VAT,etc... values.
NOT(AND(ISPICKVAL(picklistfield,'PAN'),REGEX(PANCARD__c, "[a-zA-Z]{5}-[0-9]{4}-[a-zA-Z]{1}"))).

Let me know if more help needed or any quiries.
Please mark this as answer if it works.
Vijay NagarathinamVijay Nagarathinam
Hi Lavanya,

Please use the validation rule, it will be work.

NOT( REGEX( PAN_Number__c , "[A-Za-z]{5}[0-9]{4}[A-z]{1}") )