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 257 forks source link

validation problem when try to put a part of value of the mask #154

Closed eduardonaguiar closed 8 years ago

eduardonaguiar commented 8 years ago

In my case I need to put a parcial string in a input masked so even with allowInvalidValue setted to true the model doesn't validate. If I put a complete value the model is validate.

<input id="phone" name="phone" type="text" class="form-control input-md" ng-model="data.phone" ui-mask="(999) 9999-9999" validator="required" valid-method="submit" allow-invalid-value>

If I type (000) 0000-000_ (no complete the mask) and try to validate ( $validation.validate(form) ), the method doens't execute sucess promise and doens't show the required message from input. When I console the form object the input appear in $error section as a invalid input.

I'm working on a new GUI for a old database, so the values for this data can be broken for this new mask. If the user try to alter the form with the broken data field the form is not validating. I just need that the form be validate with the broken masked data.

The allow-invalid-value supposed work for, is it?

MAbdulHalim commented 7 years ago

just add "?" like ui-mask="(?9?9?9) ?9?9?9?9-?9?9?9?9"