PatternValidator

PatternValidator

Stable Directive

Class Overview

class PatternValidator implements Validator, 
  pattern : string|RegExp
  ngOnChanges(changes: SimpleChanges) : void
  validate(c: AbstractControl) : ValidationErrors|
}

Selectors

[pattern][formControlName]

[pattern][formControl]

[pattern][ngModel]

Class Description

A Directive that adds the pattern validator to any controls marked with the pattern attribute, via the NG_VALIDATORS binding. Uses attribute value as the regex to validate Control value against. Follows pattern attribute semantics; i.e. regex must match entire Control value.

Example

<input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>

Class Details

pattern : string|RegExp
ngOnChanges(changes: SimpleChanges) : void
validate(c: AbstractControl) : ValidationErrors|

exported from forms-index, defined in forms/src/directives/validators.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/forms/index/PatternValidator-directive.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部