Rui Queirós Rui Queirós - 3 years ago 191
Javascript Question

Mask not being applied to input with ng-model

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
I get

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

Answer Source

Try to set mask as: ui-mask="999.999.999-99"

Demo fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download