This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
KurtJensen
I have found it is easier to let user enter however they want.
Then use model to strip to all numbers and then break in pieces and format before storing.
public function formatPhone()
{
$pin = preg_replace ('/[^0-9]/i',"", $this->phone); // strip all but numbers
if (!strlen($pin) == 10) return false;// Check for 10 digit phone number
if (!$pin) return false;
$area = substr($pin, 0, 3);
$prefix = substr($pin, 3, 3);
$station = substr($pin, 6, 4);
$this->phone = '('.$area.')'.$prefix.'-'.$station;
}
Last updated
1-3 of 3