# Write input mask function

**URL:** <https://forum.dimagi.com/t/write-input-mask-function/4887>\
**Category:** Uncategorized\
**Created:** [January 16, 2018, 9:56am UTC](https://forum.dimagi.com/t/write-input-mask-function/4887 "2018-01-16T09:56:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mawatta](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@Mawatta](https://forum.dimagi.com/u/Mawatta)\
**Post date:** [January 16, 2018, 9:56am UTC](https://forum.dimagi.com/t/write-input-mask-function/4887/1 "2018-01-16T09:56:43Z")

</div>

Hi,  
I want to use the input mask formatting for my phone number field. I would like to know if it is possible to customize such a formatting in commcare. I want my phone number to be 12 digits / characters and look display a format : 0000-000-000.

Than

---

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [January 16, 2018, 10:00pm UTC](https://forum.dimagi.com/t/write-input-mask-function/4887/2 "2018-01-16T22:00:20Z")

</div>

Hi Mawatta,

Unfortunately, we don't support input masks in our string inputs. We do  
support regular expressions as well as other input validation conditions  
(like string-length()).

If the field is going to be displayed at a later time (or used in reports)  
and the goal is to have the data value associated with the case in that  
format, you could use a validation condition on the input to ensure it is  
the right length, then you could use a _hidden value_ with a  
\*calculate \*expression  
like

if(not(string-length(#form/phone\_input) = 10),  
'',  
concat( substr(#form/phone\_input, 0, 4), '-', substr(#form/phone\_input,  
4, 7), '-', substr(#form/phone\_input, 7, 10)  
)

Which would take a value input by the user as a 10 digit long number (in  
the "phone\_input" question), then transform it into the format you are  
describing.

-Clayton
