Search code examples
.netasp.netregexrequiredfieldvalidator

Validation to allow single space for phone numbers


i have a validation in my .net textbox where it will take only numbers

but when i put the the phone format like

080 234234

it will not accept because of a space

how to resolve this ?

could anyone help in regular expression ?

Current expression is this [0-9]+

i want only single space ... no two spaces should be encoraged


Solution

  • [0-9]+\s?[0-9]+
    

    The question mark indicates there is zero or one of the preceding element.