dimanche 10 juin 2018

Pattern for email or telephone number

I have problem with regular expression in pattern for telephon number OR email

Code:

<input class="form__input" type="text" name="phone-or-email" placeholder="Telephone or email" pattern="^[0-9]{9}$ || [A-Za-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}" title="Telephone or email" required="required">

Pattern:

pattern="^[0-9]{9} || [A-Za-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$

telephone regular expression: ^[0-9]{9,12}$ - it's enough for me

email regular expression: [A-Za-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3} -it's ok email regular expression for me

Above code doesn't work :( I would like have one input and one pattern for telephone number and email address

Aucun commentaire:

Enregistrer un commentaire