+ Start a Discussion
newjnewj 

Validation rule


hello,

I have a text field and i want to allow users to enter only a-z letters, no special characters such as &, $.... and no space between letters

thx for you help

sumpritsumprit

Hi there,

Did you find a solution to this problem?

I am trying to acheive the same, by validating the Account Name to have a valid name instead of special characters.

thanks

 

 

Erin ShannonErin Shannon
I am trying this validation rule that and it won't work.  I copied it from the sample SSN validation rule found on SFDC help.  Can anyone tell me why it is not working?  When I test it the field accepts anything I put into it.  It is a custom text field.
 
NOT (
OR (LEN( Project_Code__c ) = 9,
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", LEFT ( Project_Code__c , 1)),
MID ( Project_Code__c, 2, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 3, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 4, 1)),
MID ( Project_Code__c, 5, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 6, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 7, 1)),
MID ( Project_Code__c, 8, 1) = "-",
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", MID ( Project_Code__c , 9,1)) ))
CurtAllen.ax323CurtAllen.ax323

Erin Shannon wrote:
I am trying this validation rule that and it won't work.  I copied it from the sample SSN validation rule found on SFDC help.  Can anyone tell me why it is not working?  When I test it the field accepts anything I put into it.  It is a custom text field.
 
NOT (
OR (LEN( Project_Code__c ) = 9,
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", LEFT ( Project_Code__c , 1)),
MID ( Project_Code__c, 2, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 3, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 4, 1)),
MID ( Project_Code__c, 5, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 6, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 7, 1)),
MID ( Project_Code__c, 8, 1) = "-",
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", MID ( Project_Code__c , 9,1)) ))



The reason it is not working is because right now the validation is making sure the field does not contain "A-Z" as a string.  Give me an idea of what you are trying to accomplish and I can assist you with this formula.
Erin ShannonErin Shannon

Thanks for getting back to me.  I figured out what I missed.  The first 2 lines.  This code worked.

NOT (
OR (LEN( Project_Code__c ) = 0,
AND (
LEN ( Project_Code__c ) = 9,
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", LEFT ( Project_Code__c , 1)),
MID ( Project_Code__c, 2, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 3, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 4, 1)),
MID ( Project_Code__c, 5, 1) = "-",
CONTAINS ("0123456789", MID (Project_Code__c , 6, 1)),
CONTAINS ("0123456789", MID (Project_Code__c , 7, 1)),
MID ( Project_Code__c, 8, 1) = "-",
CONTAINS ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", MID ( Project_Code__c , 9,1)) )))