Home > Back-end >  I need a regex to validate phone numbers which only 0 or 1
I need a regex to validate phone numbers which only 0 or 1

Time:12-01

I need a regex to validate only 0s or 1s in a phone number. For eg - 0000000000 or 1111111111 should be invalid.

CodePudding user response:

This regex will match the phone numbers with 0s and 1s

/([01*]{10})/gm

CodePudding user response:

Regex pattern for 1s and 0s only

^[0-1] $

HTML EXAMPLE

<form>
  <input type="text" pattern="^[0-1] $" title="Invalid input">
  <input type="submit">
</form>

  • Related