SoFunction
Updated on 2025-03-08

A js mobile phone number verification regular expression that is prone to errors (recommended)

Write a simple regular expression to verify the 11-digit mobile phone number. The beginning is 13, 15, 18. I wrote it like this at the beginning:

var reg = /^(13[0-9]{9})|(15[0-9]{9})|(18[0-9]{9})$/;

Running found that even 13988888877157777 can pass the verification, which means that the writing method is wrong. My original intention is to hope this:

 ^(13[0-9]{9})$ or ^(15[0-9]{9})$ or ^(18[0-9]{9})$

So the correct way to write it is:var reg = /^1[358][0-9]{9}$/;This will ensure 11 digits

The above is what the editor introduces to you. A regular expression for js mobile phone number verification that is prone to make mistakes (recommended). I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!