angularjs validate input and prevent change if invalid

前端 未结 4 1706
野性不改
野性不改 2021-01-06 11:15

I neeed an input field where I can enter only the values 1,2 or 3 so i\'m trying to build a directive which prevents all changes to the model if it doesn\'t match these valu

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 12:02

    I'd recommend using the ng-pattern-restrict directive.

    Get the library and simply decorate your input like so:

    
    

    GitHub: AlphaGit/ng-pattern-restrict

提交回复
热议问题