Skip to content

Phone Number Mask

In the Chat Platform service, you can work with phone number masks to collect a visitor's contact information.

You can set the phone number format through a mask, which helps in preventing incorrect entries such as too many or too few digits, an incorrect country code, or non-numeric characters. You define this mask in visitorFields:def for each individual placement. The default mask appears as:

"phone":{"presence": "mandatory","validation":{"mask": "+41 (XXX) XXX-XX-XX"}}

When a visitor enters a phone number in the corresponding field to request contact information, a validator receives the entire string and checks the number against the specified mask. The validator returns True if the validation is successful and False otherwise.

If a visitor enters a phone number that doesn't match the mask, they will see a message informing them that they need to correct the phone number. They must either enter a number that fits the mask or erase the number from the corresponding field. In the latter case, if the phone number entry is not mandatory, the visitor's information will still be sent.