Occasional Contributor II

Form Validation using arrays

Morning all, I have a query regarding arrays in form validation. I am trying to limit the number of characters in a username as a method of ensuring that devolved administrators are using the correct length. Correct lengths will be number based, with either 5, 6, 14 or 16 characters being allowed. I can get the limiting to work on a single array (ie 5 characters) by using array ( 0 => 10000, 1 => 99999, ) Does anyone know if it is possible to use an OR statement within an array to check the number of characters in our username scenario above? I have tried numerous formats using standard syntax for or (OR, ||, etc) but i cant seem to get it to work. I have even tried using additional variables to the array, such as array ( 0 => 10000, 1 => 99999, 2 => 100000, 3 => 999999, ) but again this fails. TIA Gordie

Re: Form Validation using arrays



I did some testing, and you may better use the IsRegexMatch validator for this purpose with the following Regex:




So this is ^\d\d\d\d\d$ => string that has exact 5 digits (\d) between the start of line (^) and the end ($); or (|) the same with 6, 14 or 16 digits.


Got how to create this validator from:


I'm quite sure that Regex Gurus can squeeze this into a much smaller regex; I'm not that experienced.


Regards, Herman

If you have urgent issues, please contact your Aruba partner or Aruba TAC (click for contact details).
Occasional Contributor II

Re: Form Validation using arrays

Hi Herman,

Sorry for the delay, I have not been about to reply.

I will try this later this week and will provide feedback to its success

Now all I have to do is remember how the wonderful world of regex works :)


Occasional Contributor II

Re: Form Validation using arrays

Thanks Herman,


I dug out my old O'reillys pocket regex book and have implemented the following

^\d{5}$|^\d{6}$ etc, replacing all of the d's with a \d{n} where n is the number of characters that you want the pattern to match

#happy_days :)

Thanks again

Search Airheads
Showing results for 
Search instead for 
Did you mean: