2

I have a zipcode input field on a visualforce page. This field could be hidden (rendered = false) based on certain needs. I have the following field validation to ensure a proper zipcode format is entered. If the zip code field is hidden the validation runs when trying to save the record. I need it to not run in this case.

NOT(REGEX( Insured_ZipCode__c , "\\d{5}(-\\d{4})?"))

2 Answers 2

4

You need to also check whether it has a value entered in it or not:

NOT(ISBLANK(Insured_ZipCode__c)) && NOT(REGEX( Insured_ZipCode__c , "\\d{5}(-\\d{4})?"))

So if you don't render it, it will be blank and will be ignored by the validation rule, but as soon as you enter a value (you render it), then it must match the regex.

0

Use AND( NOT(REGEX( Insured_ZipCode__c , "\d{5}(-\d{4})?")), Rendered = TRUE)

1
  • where is Rendered=True documented for use in the validation formulas ? I don't see it in the list of All Function Categories in the error condition formula editor.
    – rickmac
    Nov 19, 2014 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .