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
Russel MendozaRussel Mendoza 

Flow question. Don't accept spaces on inputs.

Hi Team,

I have a simple question with regards on how not to accept spaces on fields. Basically I created this field in flow(PFP) that accepts only 10 - 15 alphanumeric characters which works fine. Now I''m trying to add another validation that checks if the input has a spaces between them but unfortunatly the "contains" syntax is not working for me or am I doing something wrong in here? When I added this syntax it ruins the whole validation rule and it doesn't accept any thing.

Validation:   AND(LEN({!PFP}) >= 10 && LEN({!PFP}) <=15, REGEX({!PFP},"[\\p{L}\\s\\d]*$"), CONTAINS({!PFP},"[\\s]"))

Any help will be greatly appreciated. Thanks in advance.
Best Answer chosen by Russel Mendoza
Akhil AnilAkhil Anil
Hi Russel,

So your formula will be exactly this. This REGEX will only allow alphanumeric characters and not allow any spaces.
 
AND(
LEN(PFP) >= 10,
LEN(PFP) <= 15,
NOT(CONTAINS(PFP," ")),
REGEX(PFP,"[a-zA-Z0-9]+")
)

 

All Answers

Akhil AnilAkhil Anil
Hi Russel,

Your validation formula should be simply this.
 
AND(
LEN(PFP) >= 10,
LEN(PFP) <= 15,
NOT(CONTAINS(PFP," "))
)

Kindly mark as an asnwer if that works !
Russel MendozaRussel Mendoza
Thanks for the reply but I need the regex so it won't accept special characters like hyphen. Sorry I forgot to mention that.
Akhil AnilAkhil Anil
List all the special characters that you want to exclude
Russel MendozaRussel Mendoza
All of the special characters. The rule is to only accept alpha numeric characters. 

This code basically works for me> AND(LEN({!PFP}) >= 10 && LEN({!PFP}) <=15, REGEX({!PFP},"[\\p{L}\\s\\d]*$"))

The code above works it's just that I'm having problem on inserting this new syntax for not to accept blank spaces.
Akhil AnilAkhil Anil
Hi Russel,

So your formula will be exactly this. This REGEX will only allow alphanumeric characters and not allow any spaces.
 
AND(
LEN(PFP) >= 10,
LEN(PFP) <= 15,
NOT(CONTAINS(PFP," ")),
REGEX(PFP,"[a-zA-Z0-9]+")
)

 
This was selected as the best answer
Russel MendozaRussel Mendoza
I'm currently testing this on flow. For some reason I'm getting a server timeout when I save my flow so I'll try again a bit later but I'll let you know when it works. Thanks for your help.
Russel MendozaRussel Mendoza
Ok so I managed to saved the forumula that you gave me to the flow that I'm working on but when I tried to do a test record it gave out an error. Looks like this kind formula doesn't work in flow I guess. 
Akhil AnilAkhil Anil
Hi Russel,

What's the error that you are getting ?

I have used it in a flow and it works perfectly fine for me when I test it out.

In my case, the name of my field is "PFP" and I have used it as it is without any curly braces.

User-added image
Russel MendozaRussel Mendoza
I'm sorry about that. I tried to re-type it and it worked. I might have mistype something before. Thank you so much for your help.