Search code examples
asp.netregexvalidationminimum

Regular expression - empty or a minimum of 6 characters


I want to use an ASP:RegularExpressionValidator to enforce a minimum character count (6) but only if the field is NOT empty.

Could anyone help me with the regex for this?


Solution

  • Try this regular expression:

    ^(?:.{6,}|)$