dma_k
dma_k

Reputation: 10639

md-autocomplete ng-pattern="..." does not work

I have the issue with <md-autocomplete> component which is shown in this demo:

<md-autocomplete ng-pattern="..."> does not work. I would expect that if some text is entered into Tax field (like zzz) the field is be marked as red as only numbers [1..99] are accepted by regex ng-pattern="/^[1-9]\d?$/". Actually required works fine: when the field is empty, it is triggered as invalid.

Upvotes: 12

Views: 1477

Answers (3)

Srikanth B
Srikanth B

Reputation: 143

The issue with ng-pattern got fixed in version 1.1.14. I have updated the Demo and added latest angularjs-material.js

I have not changed ng-pattern, it remains same.

ng-pattern="/^[1-9]/"

Now the field will change to red if other than number is entered.

Upvotes: 3

wwv
wwv

Reputation: 911

That seems to have been a bug with Angular Material. It was apparently fixed in 1.1.4:
ng-pattern for md-autocomplete #9755

Here's a working demo. All I did was update the two angular-material libraries.

https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.js
https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.css

Upvotes: 11

haMzox
haMzox

Reputation: 2109

Just change your pattern by: ng-pattern="^[1-9]\d?$"

Upvotes: 2

Related Questions