Custom Form - Complex Validation Rules Help


(David Herrington) #1

Here's what I would love to achieve in my custom form.

 

The answer to one of the questions on my custom form needs to be:

  1. A required field
  2. Seven characters in total
  3. The first six characters are random numbers followed by a random letter on the end eg. 123456H

I can see how to achieve point one and two above. Any ideas on how to achieve the final step of checking that the seventh character is a letter?

 

Any help would be greatly appreciated.

 

 


(Peter McLeod) #2
Hi
 
Maybe a regex validation rule...
 
That checks if the last char is uppercase letter - as you would also have a seperate rule to check length = 7 then this wouldn't need to be handle in the regex. The rule would be set to must match.
 
[A-Z]$
 
To include check for 6 digits at start you could use: ^[0-9]{6}[A-Z]$
 
Also if you want to check the 'randomness' and see if there are sequences in the numeric part somthing such as this could be added as another rule - whic must not match:
0{2,}|1{2,}|2{2,}|3{2,}|4{2,}|5{2,}|6{2,}|7{2,}|8{2,}|9{2,}|012|123|234|345|456|567|678|789
 
Thanks
Peter

(David Herrington) #3

Thanks Peter for taking the time to reply. I’ll give that a try and let you know how I get on.