I have to have two different Regex patterns for the same ID. Reason being I have different error message requirements for all three. Problem is that the last Regex interferes with the second's leading space validation. I have tried \s
, ^\s
, [ \t]
, (?! )
and a variety of other harebrained ideas that I came up with. Same as Above regex is conflicting with StreetAddress2 and allowing leading white space. No trim that I have tried has worked. Except when I comment out the SameAsAbove.
public const string StreetAddress = @"^(?!(SAME|SAME AS ABOVE|same|same as above))[a-zA-Z0-9]{1}[a-zA-Z0-9&-\/.# ]{0,49}";
public const string StreetAddress2 = @"^(?! )[^\s][a-zA-Z0-9]{1}[a-zA-Z0-9&-\/.# ]{0,49}";
public const string SameAsAbove = @"^(?!(SAME|SAME AS ABOVE|same|same as above|Same|Same as above|Same as Above)).*$";
The first two give the message:
public const string StreetAddress = "Street may contain only alphanumeric characters, ., #, /, -, & or white space";
The last one gives this message:
public const string SameAsAbove = "Same or Same As Above is not allowed";
<asp:RegularExpressionValidator
ID="RegExpDFSRegistrationAddress"
ControlToValidate="txtDFSRegistrationAddress"
runat="server"
CssClass="Error" />
RegExpBusinessContactAddress.ValidationExpression = CommonRegularExpressions.StreetAddress2;
RegExpBusinessContactAddress.ErrorMessage = CommonErrorMessages.StreetAddress;