To be frank , i am not really familiar with all possibilities of GB phone numbers, if you could throw some light on this, i might be able to help ya.
On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1 <g1smd.em...@gmail.com> wrote: > > Thanks for the reply and information. > > > The jQuery validation routines for GB telephone numbers contain > significant errors and shortcomings. I already posted some patches > correcting many of those problems at least a month ago, but they haven't > been reviewed yet. > > > The new Python/django telephone number validation code I am proposing here > is far more comprehensive and has much more detailed range and length > checking. Similar code already works fine in PHP and Java elsewhere, but I > am having trouble converting it all to Python. > > I have added some Python logic and code to the initial RegEx patterns that > I posted yesterday, but I now need help to finish it off and get it > working. I am not at all familiar with the Python syntax and the manual is > somewhat terse and obtuse. > > I had a problem with GitHub this morning, so the pull request is now at > https://github.com/django/django/pull/324 > > The code so far, can be found at: > https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py > > I'm guessing that someone proficient in Python could finish it off in a > couple of hours or less. > > Any volunteers? > > > > > On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote: >> >> you can alternatively use jquery to validate the field, i do not have the >> link handy as m on my phone right now but google validation engine, it is >> one of the most powerful jquery validation library which also has builtin >> method of validating uk phone numbers. >> On Sep 4, 2012 5:00 AM, "g1smd.1" <g1smd...@gmail.com> wrote: >> >>> I see that there are routines for validating telephone numbers in forms >>> in Django for several countries. >>> >>> The code for that can usually be found in the forms.py file located in >>> the various country folders here: >>> https://github.com/django/**django/tree/master/django/** >>> contrib/localflavor<https://github.com/django/django/tree/master/django/contrib/localflavor> >>> >>> So far, there is nothing for GB numbers, here: >>> https://github.com/django/**django/tree/master/django/** >>> contrib/localflavor/gb<https://github.com/django/django/tree/master/django/contrib/localflavor/gb> >>> >>> I've written a bunch of RegEx patterns to get this functionality >>> started. The patterns are 100% fully tested. All that's needed is a few >>> lines of python logic to string them together. The details can be found at: >>> https://github.com/django/**django/pull/316/files<https://github.com/django/django/pull/316/files> >>> >>> My python foo is almost zero. Anyone care to have a go at getting this >>> to work? >>> >>> RegEx 1 checks the user entered something that looks like a GB telephone >>> number: >>> 020 3000 5555 >>> 02075 567 234 >>> 0114 223 4567 >>> 01145 345 567 >>> +44 1213 456 789 >>> 00 44 (0) 1697 73555 >>> 011 44 11 4890 2345 >>> and several other formats, without worrying if the format is correct for >>> this particular number (but read on). It allows for national or >>> international format, even for two common international dial prefixes. What >>> is most important is that the user enters the right number of digits. Don't >>> constrain the user to use a particular format for entry. >>> "Be lenient in what you accept, be strict in what you send." (Postel's >>> Law) >>> >>> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in >>> $2 (so you know if international or national format was used on input), and >>> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3. >>> >>> RegEx 3 tests the NSN part of the number is in a valid range and has the >>> right number of digits for that range (GB numbers can be 9 or 10 digits >>> long). This RegEx pattern is very detailed. You can say that a number is >>> possible or is invalid with this RegEx. >>> >>> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how >>> a GB number should be formatted, detailed by number length and initial >>> digits. These rules cover all GB numbers. >>> >>> The last bit is to add the 0 or +44 back on, and append the original >>> extension number (if present) and present it back to the user. >>> >>> 020 3000 5555 => Valid: 020 3000 5555 >>> 02075 567 234 => Valid: 020 7556 7234 >>> 0114 223 4567 => Valid: 0114 223 4567 >>> 01145 345 567 => Valid: 0114 534 5567 >>> +44 1213 456 789 => Valid: +44 121 345 6789 >>> 00 44 (0) 1697 73555 => Valid: +44 16977 3555 >>> 011 44 11 4890 2345 => Valid: +44 114 890 2345 >>> 0623 111 3456 => NOT VALID >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To view this discussion on the web visit https://groups.google.com/d/** >>> msg/django-users/-/**h0iG7nJrXikJ<https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ> >>> . >>> To post to this group, send email to django...@googlegroups.com. >>> To unsubscribe from this group, send email to django-users...@** >>> googlegroups.com. >>> >>> For more options, visit this group at http://groups.google.com/** >>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >>> . >>> >> > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/Zohb6P8AsaIJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Thanks & Regards ---------------------------- Amyth [Admin - Techstricks] Email - aroras.offic...@gmail.com, ad...@techstricks.com Twitter - @a_myth_________ http://techstricks.com/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.