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
sandeep reddy 37sandeep reddy 37 

how can create zip code validation rule

i have a pincode field  write only on number  limit six only how it is posible between  500000 to 900000
Best Answer chosen by sandeep reddy 37
Deepthi BDeepthi B
Hi Sandeep,

Check this code in the Validation rule: 
NOT( 
AND( (LEN(pincode__c)==6 ),(REGEX(pincode__c,'[5-9]{1}[0-9]{5}'))) 
)

Regards,
Deepthi

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please try below code
AND
(
	NOT(MailingPostalCode = ""), 
	OR
	( 
		LEN(MailingPostalCode) <>5, 
		NOT( CONTAINS("0123456789",	LEFT( MailingPostalCode, 1)) ) , 
		NOT(CONTAINS("0123456789", MID( MailingPostalCode , 2, 1)) ), 
		NOT(CONTAINS("0123456789", MID( MailingPostalCode , 3, 1)) ), 
		NOT(CONTAINS("0123456789", MID( MailingPostalCode , 4, 1)) ), 
		NOT(CONTAINS("0123456789", MID( MailingPostalCode , 5, 1)) ),
		NOT(CONTAINS("0123456789", MID( MailingPostalCode , 6, 1)) ),
		NOT
		(
			AND
			(
				MailingPostalCode > 500000 ,
				MailingPostalCode < 600000
			)
		)	
	) 
)

 
Deepthi BDeepthi B
Hi Sandeep,

Check this code in the Validation rule: 
NOT( 
AND( (LEN(pincode__c)==6 ),(REGEX(pincode__c,'[5-9]{1}[0-9]{5}'))) 
)

Regards,
Deepthi
This was selected as the best answer
sandeep reddy 37sandeep reddy 37
ya thank u  
Rupal KumarRupal Kumar

Hi Sandeep,

    Try this--
NOT( 
AND( 
OR( 
LEN (zip__c) = 0, 
REGEX(zip__c, "[0-9]{6}") 
), 
OR( 
BEGINS(zip__c,"5"), 
BEGINS(zip__c,"6"), 
BEGINS(zip__c,"7"), 
BEGINS(zip__c,"8"), 
BEGINS(zip__c,"9") 

) 
) 
)

thanks
Rupal
mirketa pvt.ltd
geeta garggeeta garg
Try this code in the validation rule:-

IF( AND(PinCode__c >=500000,PinCode__c <=900000),false,true)