1

So, I have a validation rule to validate the following requirements. However using the REGEX function, I need to exclude the ability to enter a spacebar tab and save. If a user hits the spacebar once or more without adding a letter, the validation rule should throw an error. Any thoughts?

Note: The rule need to ensure that any spacebar tabs without a letter cannot be saved.

    AND($Profile.Name <> "Sales", 
    OR( RecordType.Name = "New", 
RecordType.Name = "Discounts", 
RecordType.Name = "Upsell" ), 

    AND( 
    NOT( ISBLANK(Comment__c)), 
    NOT(REGEX(Comment__c, "(?=.*[a-zA-Z]).*"))))
2
  • What is the problem you are trying to solve. When entering text via the UI if there are trailing spaces or the user only enters a space then the space is removed automatically.
    – Eric
    Jul 19, 2017 at 2:41
  • Hi @Eric I am trying to restrict the input on the user that if they enter in a number, special character, or space without a letter, they cannot save the data in the field. At least one letter needs to be entered if they are editing that field. The VR shouldn't impact the user's ability to create or edit a record if this field is not being edited. I have another that makes it required at close, but if they touch the field at any point in time, they cannot put in simply a number, special character or space without a letter. Jul 19, 2017 at 13:18

1 Answer 1

-1

You need to check the LEN and after that use TRIM function with REGEX

LEN(Comment__c)>0 &&
AND($Profile.Name <> "Sales", 
        OR( RecordType.Name = "New", 
    RecordType.Name = "Discounts", 
    RecordType.Name = "Upsell" ), 

        AND( 
        NOT( ISBLANK(Comment__c)), 
        NOT(REGEX(TRIM(Comment__c), "(?=.*[a-zA-Z]).*"))))
1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Adrian Larson
    Jul 19, 2017 at 19:10

You must log in to answer this question.

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