Cmaskedtextfield With Varient Format

I’m trying to use the CMaskedTextField to validate a phone number for Brazil. They have different number of digits for some numbers, for example -

(00) 1234-5678 Land lines

(00) 12345-6789 Cell Phones

I was trying to use this code for the phone number but found out about the oddness between land and cell phones.


$this->widget('CMaskedTextField', 

array(

        'model' =>$model,

        'attribute' => 'int_tel',

        'mask' => '(99) 9999-9999? x9999',

));



Any ideas or suggestions how to work around the problem using this type of masked edit?

THANKS!

Sandy

Hi! Any solution to this? I’m dealing with a legacy system and also need to do this.

$this->widget('CMaskedTextField', array(    'model' => $model,    'attribute' => 'int_tel',    'clientOptions' => array(        'mask' => array('(99) 9999-9999', '(99) 99999-9999'),        'greedy' => false    ),));

This allows:

  • (11) 1234-5678
  • (11) 91234-5678

Much cleaner than trying to force optional digits into one mask.