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
SASA 

validation rule to include only number comma and space

Hi,
I created a custom field TEST_User_ID__c. User should only enter number (0-9), Space and Comma. Can someone please help with validation rule using Regex.

Thank you
Steven NsubugaSteven Nsubuga
Try 
NOT(REGEX(TEST_User_ID__c,"^[0-9" ",.* ]+$"))
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi sony,

The below Regex worked for me .Try the below code in your validation rule:
 
IF(
ISBLANK( TEST_User_ID__c) , false , 
NOT(REGEX(TEST_User_ID__c,"^[0-9, *]+$"))
)

 
NagendraNagendra (Salesforce Developers) 
Hi Sony,

Please try this.
AND(
NOT(ISBLANK(TEST_User_ID__c)),
NOT(REGEX(TEST_User_ID__c,"^[0-9,.*]+$"))
)
Use the insert field button to select the field API Name of the TEST_User_ID field.

Please let us know if this helps.
 
Prema -Prema -
You can try this one..
NOT(CONTAINS(TEST_User_ID__c," ") ||(REGEX(TEST_User_ID__c, "[0-9]")) ||CONTAINS(TEST_User_ID__c,"," ))

 
Akshay_DhimanAkshay_Dhiman
Hi Sony,

Try This code.

AND( 
NOT(ISBLANK( TEST_User_ID__c )), 
NOT( REGEX( SUBSTITUTE( TEST_User_ID__c , " ", "") ,"^[0-9,.*]+$")) 

)


Thanks
Akshay