# Phone Number Format

**URL:** <https://forum.servoy.com/t/phone-number-format/10527>\
**Category:** Classic Servoy\
**Created:** [April 14, 2009, 3:57am UTC](https://forum.servoy.com/t/phone-number-format/10527 "2009-04-14T03:57:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliaaano](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@juliaaano](https://forum.servoy.com/u/juliaaano)\
**Post date:** [April 14, 2009, 3:57am UTC](https://forum.servoy.com/t/phone-number-format/10527/1 "2009-04-14T03:57:25Z")

</div>

I have a phone number field typed as VARCHAR in my database. I’d like to have a format that permits the user only to enter numbers in this field. I’ve noticed the use of ‘#’ as a format mask for numbers, however if I use it I will be forcing the user to enter the exact number of digits defined by the quantity of # (i.e. ### == 777, not 77 or 7777).

I would like the phone number field to behave just like if it was an Integer the dataprovider behind it.

Any Suggestions?

Thank you.

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [April 14, 2009, 6:39am UTC](https://forum.servoy.com/t/phone-number-format/10527/2 "2009-04-14T06:39:34Z")

</div>

You can use a pipe (|).  
All in before is the format, all after is for entering the data. You can leave that empty and the user can type whatever he/she wants.

---

<div class="post-metadata">

**Author:** ![juliaaano](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@juliaaano](https://forum.servoy.com/u/juliaaano)\
**Post date:** [April 15, 2009, 7:26am UTC](https://forum.servoy.com/t/phone-number-format/10527/3 "2009-04-15T07:26:52Z")

</div>

The use of pipe (I) doesn’t work in this case. For example, I tried to use the formats ‘#|’ and ‘########|’. The first only allowed me to enter one digit max when the second forced me to enter 8 digits at least. I want a format where I can enter as many digits I want [0-9], only limited by the length of the database column.

It is something like in regexp: [0-9]\*

Thank you very much for the attention, I appreciate if you or someone can help me again.

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [April 15, 2009, 7:42am UTC](https://forum.servoy.com/t/phone-number-format/10527/4 "2009-04-15T07:42:13Z")

</div>

Hi Juliano,

I think the easiest option is to create a method like this:

```auto
function onDataChangePhoneNumber()
{
	var _new = arguments[1];
	phonenumberfield = _new.replace(/[^0-9]/g, "");
}

```

and put that on the onDataChange of your phonenumber field.
