I use masked input yii2 , put the following rule:

'mask' => '+7(999)999-99-99', 

and ran into a problem, for example, I type three characters, remove the focus from the input, and the value was deleted, I need to somehow check that the user has entered all the characters to the end, I try to check the number of characters through jquery, constantly returns 16 regardless of how many characters there are. can someone come across?

    1 answer 1

    Thank you all, I found the answer to my question myself, if anyone needs it, here’s the code

     <?php echo MaskedInput::widget([ 'name' => 'tel', 'mask' => '+7(999)999-99-99', 'options'=>[ 'class'=>'form-control tel_input', ], 'clientOptions'=>[ 'clearIncomplete'=>true ] ]); ?> 

    The clearIncomplete option removes the clearIncomplete value when the focus is lost, provided that the input is not completely filled.