Skip to main content
Hi, I'm looking to create a validation rule that limits the use of special characters in the First Name field. We've recently experienced some bot traffic causing problems on a registration page to our Salesforce Community.

When a user enters the first name, it can only include a-z or A-Z and the following special characters ( - ,  , '). Basically, I'm only allowing the user to enter first names that only have Alphabetic characters in lower or upper case. In addition, I'm allowing the user to use hyphens, spaces, and apostrophes.

Finally, I'd like the formula to require that the first letter of the First Name be an alphabetical character. Could you give me some help on the REGEX expression that would be necessary to fulfill these requirements?
3 respuestas
  1. 30 mar 2020, 22:27
    Hi Noah,

    Try below snippet.

    AND(

    ISNEW(),

    NOT(ISBLANK(Field__c)),

    NOT(REGEX(Field__c,"^[a-zA-Z0-9_]*$"))

    )

    Review below link which has few more examples.

    https://help.salesforce.com/articleView?id=000334073&type=1&mode=1

    https://success.salesforce.com/answers?id=90630000000D7V4AAK

    http://vinaychaturvedi.com/blog/learn-regex-in-salesforce-with-examples/

    Hope above information was helpful.

    Please mark as Best Answer so that it can help others in the future.

    Thanks,

    Vinay Kumar
0/9000