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
Diptonil Deka 8Diptonil Deka 8 

how to restrict specific string chahracter in between a word or at suffix of the word?

is it possible to restrict string ' dr/DR/dR/MR/mr/Mr or Test or Clinic or Dummy or specific characters' in name fields of  an custom object by validation rule? I am able to restrict when used as prefix.

What to do to restrict in middle of an word in the name fields or as suffix of the name in the name field?

Eg: Amanclinic  // should not allow clinic or other mention strings.
Eg: Amandummykumar  //shouldnot allow in middle of the name to                                                enter in the string. Should throw validation                                                                                                       error

my validation rule:

AND(OR(CONTAINS( First_Name__c , 'DR'),CONTAINS( First_Name__c , 'MR'),CONTAINS( First_Name__c , 'Dr'),CONTAINS( First_Name__c , 'Mr'),
CONTAINS( First_Name__c , 'Test'),CONTAINS( First_Name__c , 'Clinic'),CONTAINS( First_Name__c , 'Dummy'),NOT(REGEX( First_Name__c , "^[a-zA-Z_]*$")),CONTAINS( Middle_Name__c , 'DR'),CONTAINS( Middle_Name__c , 'MR'),CONTAINS( Middle_Name__c , 'Dr'),CONTAINS( Middle_Name__c , 'Mr'),CONTAINS( Middle_Name__c , 'Test'),
CONTAINS( Middle_Name__c , 'Clinic'),CONTAINS( Middle_Name__c , 'Dummy'),NOT(REGEX( Middle_Name__c , "^[a-zA-Z_]*$")),CONTAINS( Last_Name__c , 'DR'),CONTAINS( Last_Name__c , 'MR'),
CONTAINS( Last_Name__c , 'Dr'),CONTAINS( Last_Name__c , 'Mr'),CONTAINS( Last_Name__c , 'Test'),CONTAINS( Last_Name__c , 'Clinic'),
CONTAINS( Last_Name__c , 'Dummy'),NOT(REGEX( Last_Name__c , "^[a-zA-Z_]*$"))),(RecordType.Name = 'Doctor'))
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Diptonil,
 
Validation rule: AND(OR(CONTAINS( Name , 'DR'),CONTAINS( Name , 'MR'),CONTAINS( Name , 'Dr'),CONTAINS( Name , 'Mr'),
CONTAINS( Name , 'Test'),CONTAINS( Name , 'Clinic'),CONTAINS( Name , 'Dummy')))

I was testing a similar implementation where I am checking the mr/dr/dummy/test in the name field for an account record with the above validation rule and it gave me the error even when the text being checked is in the middle of the word, please find the below snapshots for the same.

I think you will have to check your validation rule.

User-added imageUser-added image

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.