I'm trying to validate a textbox containing a variety of accepable inputs:
- "123456789"
- "123456789+1"
- ""
I'm using this regular expression to validate the first two conditions:
^[0-9]{9}\+[0-9]$
But now I can't figure out how to allow the user not to enter anything, I've tried things like encapsulating the expression in ()?
, or changing the {9}
to {0,9}
, but this allows for a variable number of numbers in the first group (as it MUST be 9, or none)
Any help would be greatly appreciated!!