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
Kirtan Patel 9Kirtan Patel 9 

REGEX Validation rule to prevent number in text field

I have a requirement to prevent Numeric values in a Text Field and first letter in text field should be capitalized. 

I have tried many times but its not working, any help would be appreciated :
AND( RecordType.DeveloperName == 'Home_Lending', 
OR( 
AND(NOT(ISBLANK(FirstName)),OR(REGEX( FirstName, '\\d+'),LEFT(UPPER(FirstName),1) <> LEFT(FirstName,1))), 
AND(NOT(ISBLANK(LastName)),OR(REGEX( LastName, '\\d+'),LEFT(UPPER(LastName),1) <> LEFT(LastName,1)))

)
Best Answer chosen by Kirtan Patel 9
Alain CabonAlain Cabon
@Kirtan Patel

You can perhaps use TRIM everywhere for FirstName and LastName.

Otherwise, there is also the problem of numbers inside a text: ( ABC123DEF )

REGEX( TRIM( FirstName ) , '.*\\d+.*')           // characters before or after a number could exist.
 

All Answers

Alain CabonAlain Cabon
@Kirtan Patel

You can perhaps use TRIM everywhere for FirstName and LastName.

Otherwise, there is also the problem of numbers inside a text: ( ABC123DEF )

REGEX( TRIM( FirstName ) , '.*\\d+.*')           // characters before or after a number could exist.
 
This was selected as the best answer
Kirtan Patel 9Kirtan Patel 9
@ Alain Cabon : Thanks very much :) Its working as expected