In the list valuation formula you could do:
=OR([Field]="", LEN([Field])=9)
This would allow the field to be blank or have 9 characters.
EDIT
Modifying the formula from your link would look like:
=OR([New NI No.]="", (LEN([New NI No.])=9)
+(IF(OR((AND(CODE(MID([New NI No.],1,1))>64,
CODE(MID([New NI No.],1,1))<91)),
(AND(CODE(MID([New NI No.],1,1))>96,
CODE(MID([New NI No.],1,1))<123))),1,0))
+(IF(OR((AND(CODE(MID([New NI No.],2,1))>64,
CODE(MID([New NI No.],2,1))<91)),
(AND(CODE(MID([New NI No.],2,1))>96,
CODE(MID([New NI No.],2,1))<123))),1,0))
+(CODE(MID([New NI No.],3,1))>47)
+(CODE(MID([New NI No.],3,1))<58)
+(CODE(MID([New NI No.],4,1))>47)
+(CODE(MID([New NI No.],4,1))<58)
+(CODE(MID([New NI No.],5,1))>47)
+(CODE(MID([New NI No.],5,1))<58)
+(CODE(MID([New NI No.],6,1))>47)
+(CODE(MID([New NI No.],6,1))<58)
+(CODE(MID([New NI No.],7,1))>47)
+(CODE(MID([New NI No.],7,1))<58)
+(CODE(MID([New NI No.],8,1))>47)
+(CODE(MID([New NI No.],8,1))<58)
+(IF(OR((AND(CODE(MID([New NI No.],9,1))>64,
CODE(MID([New NI No.],9,1))<91)),
(AND(CODE(MID([New NI No.],9,1))>96,
CODE(MID([New NI No.],9,1))<123))),1,0))
=16)
I've tried to simplify this and stripped out all the validation in the middle (which specifies what each character should be) and just tried to write validation for the following:
accept 0 OR 9 characters in length.
Tried the following: =OR( (LEN([Field])=0), (LEN([Field])=9) =1). and also:
=OR([Field]="", (LEN([Field])=9) =1)
Under the above validation, entering anything (any characters at all) results in our custom validation message being shown (even 9 characters results in same error).
– Mark Nov 19 '13 at 09:35