# Check email/ phone number formatting

**URL:** https://community.silverfin.com/t/check-email-phone-number-formatting/1855
**Category:** Templates
**Created:** [July 30, 2020, 1:43am UTC](https://community.silverfin.com/t/check-email-phone-number-formatting/1855 "2020-07-30T01:43:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dominic](https://community.silverfin.com/u/dominic)
#### Post date: [July 30, 2020, 1:43am UTC](https://community.silverfin.com/t/check-email-phone-number-formatting/1855/1 "2020-07-30T01:43:22Z")

</div>

Hi,

1. Is it possible to check if phone numbers field have 10 digits and if not display warning
2. Is there a way auto format a phone number input to: xxx-xxx-xx
3. Check if email address is in an xxxx@xxxx.xxx format and if not display warning

Thanks,

Dominic

---

<div class="post-metadata">

### Author: ![Jelena\_Sutova](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/jelena_sutova/32/599_2.png) [@Jelena\_Sutova](https://community.silverfin.com/u/Jelena_Sutova)
#### Post date: [July 30, 2020, 1:08pm UTC](https://community.silverfin.com/t/check-email-phone-number-formatting/1855/2 "2020-07-30T13:08:29Z")

</div>

Hi @dominic

Thank you for your questions.

**Telephone number**

1. Is it possible to check if phone numbers field have 10 digits and if not display warning
2. Is there a way auto format a phone number input to: xxx-xxx-xx

Yes, both things are possible.  
Here is code example:

```auto

{% comment %}Checking if telephone number contains 10 digits{% endcomment %}
{% if custom.telephone.number != blank and telephone_number.size != 10 %}
  {% ic %}{::warningtext}Telephone number should contain 10 digits{:/warningtext}{% endic %}
{% endif %}

{% comment %}Telephone number format to display{% endcomment %}
{% capture telephone_number_to_display %}{% assign phone = telephone_number | split:"" %}{{ phone[0] }}{{ phone[1] }}{{ phone[2] }}-{{ phone[3] }}{{ phone[4] }}{{ phone[5] }}-{{ phone[6] }}{{ phone[7] }}{{ phone[8] }}{{ phone[9] }}{% endcapture %}

{% comment %}Telephone number input / preview mode{% endcomment %}
{% ic %}{% input custom.telephone.number placeholder:"Phone number" %}{% endic %}
{% nic %}{{ telephone_number_to_display }}{% endnic %}

```

**E-mail address**

1. Check if email address is in an xxxx@xxxx.xxx format and if not display warning

This is also possible.  
Code example:

```auto
{% capture email_address %}{{ custom.email.address }}{% endcapture %}

{% comment %}Checking if e-mail address contains symbols "@" and "." {% endcomment %}
{% stripnewlines %}
{% if custom.email.address != blank %}
  {% unless email_address contains '@' %}
    {% comment %}e-mail addrress does not contains "@"{% endcomment %}
    {% ic %}{::warningtext}E-mail address should contain @ symbol{:/warningtext}{% newline %}{% endic %}
      {% else %}{% comment %}e-mail addrress contains "@"{% endcomment %}
        
        {% assign email_address_part = email_address | split:"@" %}
        
        {% comment %}Checking if first part of e-mail address contains "."{% endcomment %}
        {% assign email_address_part1 = email_address_part[0] %}
          {% if email_address_part1 contains "." %}
            {% ic %}{::warningtext}Beginning of e-mail address {{ email_address_part1 }} should not contain "." {:/warningtext}{% newline %}{% endic %}
          {% endif %}
        
        {% comment %}Checking if first part of e-mail address contains "."{% endcomment %}
        {% assign email_address_part2 = email_address_part[1] %}
          {% unless email_address_part2 contains "." %}
            {% ic %}{::warningtext}End of e-mail address {{ email_address_part1 }} should contain "." {:/warningtext}{% newline %}{% endic %}
          {% endunless %}
          
  {% endunless %}
{% endif %}
{% endstripnewlines %}

{% input custom.email.address placeholder:"E-mail address" assign:email_address %}

```

Please let us know if you need any additional information.

Jelena

---

<div class="post-metadata">

### Author: ![dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dominic](https://community.silverfin.com/u/dominic)
#### Post date: [August 7, 2020, 11:57pm UTC](https://community.silverfin.com/t/check-email-phone-number-formatting/1855/3 "2020-08-07T23:57:39Z")

</div>

Thanks Jelena!

---

<div class="post-metadata">

### Author: ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)
#### Post date: [August 10, 2020, 9:15am UTC](https://community.silverfin.com/t/check-email-phone-number-formatting/1855/4 "2020-08-10T09:15:22Z")

</div>


