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
Jérôme PijpersJérôme Pijpers 

regex for allowing number between 1 and 999999

Hey there im creating a webform with visual workflow
There is this field where i need the attentant to fill in a number between 1 and 999999 there should be no spaces allowed. so input 12 435 should not be allowed

Does anyone know the correct Regex for this in visual workflow ?

Best Answer chosen by Jérôme Pijpers
Alain CabonAlain Cabon
1) Logically, the field should be a number and the validation rule is trivial:

{!Test_number} < 1000000 && {!Test_number} > 0

2) If the field is of type text, just prevent the beginning of this text with a zero.

NOT(BEGINS("0",{!test_text})) && REGEX({!test_text},"[0-9]{1,6}")

One to six figures only [0-9]{1,6} ) and cannot begin with zero  ( NOT(BEGINS("0",{!test_text}))  )

User-added image

Alain

All Answers

Prakash NawalePrakash Nawale
Hi Jelly,

I would suggest go with validation rule to validate field value is number and belongs to range.
you can use ISNUMBER() to validate.
Alain CabonAlain Cabon
1) Logically, the field should be a number and the validation rule is trivial:

{!Test_number} < 1000000 && {!Test_number} > 0

2) If the field is of type text, just prevent the beginning of this text with a zero.

NOT(BEGINS("0",{!test_text})) && REGEX({!test_text},"[0-9]{1,6}")

One to six figures only [0-9]{1,6} ) and cannot begin with zero  ( NOT(BEGINS("0",{!test_text}))  )

User-added image

Alain
This was selected as the best answer
Jérôme PijpersJérôme Pijpers

Hey Alain,

Thanks for your accurate answer, that really helps :)