【发布时间】:2018-10-17 08:02:44
【问题描述】:
我想在我的密码字段上创建一些自定义验证器,以检查用户何时输入她的密码。其中一个验证器是小写验证器。
这是我编写的自定义验证器代码
lowerCaseValidator(control: FormControl): { [key: string]: boolean } | null {
if (control.value === '?=.*[a-z]') {
return {'lowerCase': true};
}
console.log(control.value);
return null;
}
但它不起作用!
【问题讨论】:
-
为什么会这样?
===不是正则表达式匹配器!! -
你可以使用.match