[thelist] Validating Irish Phone Numbers

James Hardy evolt at weeb.biz
Wed Dec 8 11:19:22 CST 2004


Hi All,

I run a site where people registering must give their telephone numbers. 
Currently the site is open to customers from the UK and Éire.

Naturally we want some validation of the numbers. For the British 
numbers this is no problem as we are familiar with the format and have 
written a set of regular expressions to handle it (see tip). However we 
don't really have any clear idea of the format of Irish numbers. If 
there are any Irishmen (or women) on the list, or anyone who just 
happens to know, could they please help

Thanks

James

<tip type="Validating UK Phone Numbers" author="James Hardy">
Once stripped of all formating, most British phone numbers can be 
validated with a set of simple regular expressions.

    //landline numbers are 11 digits (sometimes 10) and begin 01 or 02
    var ltelf = /0[1-2][0-9]{8,9}/;

    //mobile and pager numbers are always 11 digits long and begin 07
    var mtelf = /07[0-9]{9}/;

    //to test for either landline or mobile
    var xtelf = /0[1-2,7]{9,10}/;

Special rate numbers beginning 08 and 09 do not follow this format
Numbers beginning 05 are "Business" numbers and have been mainly adopted 
as numbers for VOIP though they are very rare and can probably be 
ignored. (would be /05[0-9]{9}/ though)
Numbers beginning 03, 04 and 06 are not yet used
</tip>


More information about the thelist mailing list