Regex : Phone number starting with 06 or 07

后端 未结 5 1778
北海茫月
北海茫月 2021-01-26 22:02

I have this function which works only for 10 digits.

function telValide( tel )
{
    var reg = new RegExp(\'^[0-9]{10}$\', \'i\');
    return reg.test(tel);
}
<         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-26 22:45

    '^0(6|7) [0-9]{8}$'
    

    Or if you mean you want the numbers without a space:

    '^0(6|7)[0-9]{8}$'
    

    Check out some excellent regex tutorials here and here.

提交回复
热议问题