Phone numbers formatting

Incremental

Member
Hi,
as some users do not fill correctly phone numbers :
- with spaces or not
- I got once accentuated chars instead of numbers !

...is it possible to have something formatting numbers ?
ie : 00-00-00-00-00

I would like to store 01-00-00-00-00 when people type :
- 01 00 00 00 00
- 01.00.00.00.00
- 0100000000
- 33 1 00 00 00
- 33 (0)1 00 00 00

Thanks
 
Until recently the best you could do was to use the regex validation icon to check formatting - but that only gives user an error if they get the formatting wrong.

I believe that Hugh has recently implemented jQuery masking on input fields which (I am guessing) controls user input on a character-by-character basis as they are typing - whilst I haven't yet used it (and don't know the jQuery syntax), this would seem to provide what you are looking for.
 
With regex (or php) validation you can also do a replace, so returning the modified string.
 
Regex is difficult to learn and tricky to get right, but you might find it worth the effort because it is VERY powerful.

I use this regex for phone validation:
Code:
/^(([0][1][\d]{3,3} [\d]{5,6})|([0][2][\d] [\d]{3,4} [\d]{4,4}))?$/
The first and last "/" delimit the regex. The "/^" means start at the beginning of the string and don't skip leading characters before the match. The last "$/" means finish at the end of the string and don't match if there are trailing characters after the match.

Then the (land line) number needs to be either:
01 followed by 3 digits followed by a space followed by 5 or 6 digits
OR
02 followed by a digit followed by a space followed by 3 or 4 digits followed by a space followed by 4 digits.

The brackets group the OR clauses and the | means "OR".

So not that difficult to understand, and VERY powerful.
 
the field element as Sophist said has a input mask option (under the formatting tab)
Its sing digitalbush.com/projects/masked-input-plugin/

So I think the mask would be:

Code:
99-99-99-99-99
 
Wow ! it rocks !
Do you agree if I add the URL in the wiki ?

Just for the fun, I had a user who typed a phone number with french accentuated characters.
With a Regex and a mask, it will never happen anymore :D
 
sure if you want to make a new page for this go for it - I think I added a small entry to the field element yesterday, describing the feature though.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top