skip to Main Content

I need a regex to validate only 0s or 1s in a phone number. For eg – 0000000000 or 1111111111 should be invalid.
Also my phone number range is from 7-15 only. Below is my regex [0-9]{7,15}
it should add validation in the regex to invalidate only 0 and only 1 in the phone number

2

Answers


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

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

    Login or Signup to reply.
  2. 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>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search