Validate a field which accept 0,1,2,3,4,5,6

Certified Senior Developer

HI Team,

I stuck on feild validation which will accept only below combination:

it can be 


or 0,1 or 1,2 combinations with all numbers or it can be only value which is less than 6 

I am able to achieve with below code



if user enters like 1,2,,,,,,, or 1,2,25 this is accepting , because it is under stripwith value i have added,  how can we validate ?

might be to use split with comma and use contains functions and also how we can remove comma at last ?

Any good suggestions ?

  Discussion posts and replies are publicly visible