W3C home > Mailing lists > Public > public-xformsusers@w3.org > September 2017

Re: Telephone number type

From: Steven Pemberton <steven.pemberton@cwi.nl>
Date: Tue, 12 Sep 2017 11:52:31 +0200
To: " XForms" <public-xformsusers@w3.org>, "Steven Pemberton" <steven.pemberton@cwi.nl>
Message-ID: <op.y6f5ptihsmjzpq@steven-xps>
By the way, the very fact that this was hard to do is a good argument for  
including it...

Steven

On Tue, 12 Sep 2017 11:43:04 +0200, Steven Pemberton  
<steven.pemberton@cwi.nl> wrote:

> While we're at it, since it is a regularly occurring field in forms, how  
> about adding a telephone number type?
>
> I went looking for suitable standards to reference, and I found this:
>
> 	E.123 : Notation for national and international telephone numbers,  
> e-mail addresses and web addresses
> 	http://www.itu.int/rec/T-REC-E.123-200102-I/en
>
> This is actually about how to represent telephone numbers on printed  
> materials, but seems usable.
>
> It doesn't give a formal syntax, only examples and descriptions, from  
> which I extract the following syntax:
>
>    telephone: international | local.
>    international: "+" digits+
>    local: prefix? digits+
>    prefix: "(" digits+ ")"
>    digits: digit (spacing digit)?
>    digit: ["0"-"9"]
>    spacing: " " | "-"
>
> However, looking at  
> https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers
> some countries seem to expect to be able to bracket the area code even  
> in an international number, so we should be a bit laxer; for instance:
>
>    telephone: prefix? area? digits+
>    prefix: "+" digits+
>    area: "(" digits+ ")"
>    digits: digit (spacing digit)?
>    digit: ["0"-"9"]
>    spacing: " "+ | "-"
>
> I think this regexp covers it:
>
> 	"+"? digs+ ("(" digs+ ")" digs+)?
> where:
> 	digs: [0-9] ("-" [0-9])?
>
> and after every terminal there may follow spaces.
>
> That produces this monstrosity:
>
>    <pattern value="^\ *\+?([0-9]\ *(\-\ *[0-9]\ *)?)+(\(([0-9]\ *(\-\  
> *[0-9]\ *)?)+\)\ *([0-9]\ *(\-\ *[0-9]\ *)?)+)?\ *$"/>
>
> which you can try out here (scroll to the bottom):
>
>    http://homepages.cwi.nl/~steven/forms/tests/email.xml
>
> Let me know if you find cases that don't work.
>
> Steven
Received on Tuesday, 12 September 2017 09:52:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:37:48 UTC