1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice
  2. If you update to Joomla 3.9.16, you will have to update Fabrik from the latest GitHub version, to fix a bug introduced in Joomla, which makes it impossible to list front end folder locations in backend JForms. This affects things like template selection.
    Dismiss Notice

Phone numbers formatting

Discussion in 'Standard Support' started by Incremental, Dec 30, 2013.

  1. Incremental

    Incremental Member

    Level: Community
    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
     
  2. Sophist

    Sophist Well-Known Member

    Level: Community
    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.
     
  3. troester

    troester Well-Known Member Staff Member

    Level: Community
    With regex (or php) validation you can also do a replace, so returning the modified string.
     
  4. Incremental

    Incremental Member

    Level: Community
    Thanks,
    regex are chinese for me, but I'll try replace sprintf possibilities
     
  5. Sophist

    Sophist Well-Known Member

    Level: Community
    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 (Text):
    /^(([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.
     
    jfquestiaux likes this.
  6. rob

    rob Administrator Staff Member

    Level: Community
    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 (Text):

    99-99-99-99-99
     
     
    Incremental likes this.
  7. Incremental

    Incremental Member

    Level: Community
    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
     
  8. rob

    rob Administrator Staff Member

    Level: Community
    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.
     
  9. Incremental

    Incremental Member

    Level: Community
    Thanks Rob,
    I completed with a few samples.
     

Share This Page