I am trying to create a computer field that automatically formats phone numbers like so: xxx.xxx.xxxx

The numbers come from user input, and they will be displayed on each user page (I've added fields to Drupal's user profiles so that they include contact info)

How do I do that? Never used computed fields before, but I believe it's the solution to what I'm trying to do....

  • 1
    where the phone number is coming from - user submits a form?
    – oksana-c
    Jan 13, 2016 at 19:57
  • In addition to "where from", please also tell us where are you planning to display them, as this might affect the answers.
    – Mołot
    Jan 13, 2016 at 20:49
  • Hi @oksana-c and @Molot! Thanks for commenting.... The numbers come from user input, and they will be displayed on each user page (I've added fields to drupals users so that they include contact info) Jan 13, 2016 at 22:18
  • please edit this into your question. Also, you added fields to user profiles, not users ;)
    – Mołot
    Jan 13, 2016 at 22:32

1 Answer 1


Try Masked Input module. It allows you to create a text field with mask that you can setup custom (e.g. 999.999.9999). When user enters info into the field with masked input, the information entered is formatted automatically and stored into database with that exact format. So the output of formatted information becomes that much easier.

One drawback of this module is that it provides formatting only if user has JS enabled in the browser. If JS is disabled, you will rely on user to enter info in the desirable format. You can also ask the user to provide info in specific format by entering field description as a fallback (e.g. "Enter your phone number as follows - xxx.xxx.xxxx). I've used this module on websites with big user base, and I can tell that users very rarely have JS disabled when they fill up forms.

  • Hm, is there a way to it without downloading a module? Jan 13, 2016 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.