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
Syam Reddy 11Syam Reddy 11 

Validation rule for PAN Number

I have a requirement for PAN Number field should include 5 text, 4 Number and 1 Text characters should include for that i wrote validation rule.
Rule passed succesfully, but record is not saving in any formates. Can you please let me know the my mistake.

NOT(AND( 
(REGEX( PAN_Number__c , "[A-Z][a-z]{5}[0-9]{4}[A-Z][a-z]{1}") ), 
LEN( PAN_Number__c) <> 10))

User-added image
Thanks in Advance!
SyamReddy.
Best Answer chosen by Syam Reddy 11
GauravendraGauravendra
Hi Syam,

The correct way to check whether charachter is either in small or capital is : [A-Za-z]
Try this :
NOT( 
AND( 
REGEX(Pan_Card__c,"[A-Za-z]{5}[0-9]{4}[A-Za-z]{1}") , 
LEN(Pan_Card__c) =10 
) 
)

OR you can remove the length check by giving the field length as 10. In this way the first check will do.

All Answers

GauravendraGauravendra
Hi Syam,

The correct way to check whether charachter is either in small or capital is : [A-Za-z]
Try this :
NOT( 
AND( 
REGEX(Pan_Card__c,"[A-Za-z]{5}[0-9]{4}[A-Za-z]{1}") , 
LEN(Pan_Card__c) =10 
) 
)

OR you can remove the length check by giving the field length as 10. In this way the first check will do.
This was selected as the best answer
Syam Reddy 11Syam Reddy 11
Thanks Guruvendra!!