how to validate input for phone number with start of +966 only?

I'm trying to creating validation for input so the user can only input number start with +966 then 9 numbers like +966123456789

this is what i'm using but it doesn't do what i need

<input name="mobile" type="tel" pattern="^\d{13}$" required>

it gives 13 numbers the plus and 12 numbers but i need it to start with +966 only

1 answer

  • answered 2018-11-07 21:41 Tomm

    <input name="mobile" type="tel" pattern="^\+966\d{1,9}$" title="validation message here" required>