简体   繁体   中英

Verifying country code and remove 0 after country code if exist at input type tel html5

How can I verify that the user fills in the telefon number starting with +46 and not using a 0 after +46

  • Like +46700401008 and not 0700401008.
  • Also remove 0 if user fills in +460700401008.

I understand the type tel supports pattern which I understand uses Regex.. See below an example.

Enter your phone number:

Format: 123-456-7890

If you want to use type="tel" :

<input type="tel" id="phone" name="phone"
       pattern="\+46\d{9}"
       required>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM