Angular Reactive Forms pattern validation: Invalid regular expression

前端 未结 2 1014
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 02:53

I have a regex for Australia phone number validation working in an AngularJS website. I have set the exact pattern in the Reactive Forms validator as follows:

 V         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 03:27

    Pass pattern as string, without / which are the delimiters for regex

    Validators.pattern('^({0,1}((0|+61)(2|4|3|7|8))){0,1}( |-){0,1}[0-9]{2}( |-){0,1}[0-9]{2}( |-){0,1}[0-9]{1}( |-){0,1}[0-9]{3}$/')

提交回复
热议问题