angular-ui / ui-mask

Mask on an input field so the user can only type pre-determined pattern
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
MIT License
391 stars 258 forks source link

Mask not being properly formatted #231

Closed Rui90 closed 6 years ago

Rui90 commented 6 years ago

I have the following input:

<input type="text" id="cpfcnpj" ng-model="PersonalIdentificationNumber" ui-mask-placeholder="" ui-mask="000.000.000-00" name="PersonalIdentificationNumber" model-view-value="true" required="" readonly="" class="ng-pristine ng-not-empty ng-valid ng-valid-required ng-touched"> But when I receive data to fill the input and apply that same data to the ng-model:

$scope.PersonalIdentificationNumber = result.Result.PersonalIdentificationNumber;

The mask is not being properly formatted. Instead of 000.000.000-00 I get 00000000000.

Already tried this solution and also with: $("#cpfcnpj").attr('mask', '000.000.000-00'); But none of them works.

Rui90 commented 6 years ago

Just found what was wrong with it:

I set the mask to: '999.999.999-99';