Formatting phone numbers with Cleave

itsjakefromstatefarm:
Does anyone have any experience formatting phone numbers with Cleave like this?:

(818) 238-0172

Here are the Cleave options I’m using, but to no avail:

{
    "cleaveOptions": {
    "phone": true,
    "phoneRegionCode": "US",
    "blocks": "[3, 3, 4]",
    "delimiters": "['(', ') ', '-']",
    "numericOnly": true
}

Andrew Dam:
Give this a try:

{
                "blocks": [0, 3, 0, 3, 4],
                "delimiter": " ",
                "delimiters": ["(", ")", " ", "-", "-"],
                "lowercase": false,
                "numericOnly": true,
                "uppercase": false
            }

itsjakefromstatefarm:
Here is what that produced:

image


itsjakefromstatefarm:
I found it


itsjakefromstatefarm:
Here’s what works:


itsjakefromstatefarm:

"cleaveOptions": {
                    "blocks": [0, 3, 0, 3, 4],
                    "delimiter": " ",
                    "delimiters": ["(", ")", " ", "-", "-"],
                    "lowercase": false,
                    "numericOnly": true,
                    "uppercase": false
                }

itsjakefromstatefarm:
Needed to remove the “phone” and “US” options.