export interface ValidatorFn {
(c: AbstractControl): ValidationErrors | null;
}
export declare type ValidationErrors = {
[key: string]: any;
};
export declare class FormControl extends AbstractControl {
constructor(formState?: any, validator?: ValidatorFn | ValidatorFn[] | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
static EMAIL_REG = new RegExp('\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}');
static email(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => { ①
if (!EMAIL_REG.test(control.value)) { ②
return { ③
errMsg: '请输入正确的邮箱地址'
};
}
return {}; ④
};
}
<p *ngIf = "!email.valid && email.touched">{{email.errors.errMsg}}</p>
static EMAIL_REG = new RegExp('\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}');
static email(emailForm: FormControl): ValidatorFn { ①
return (control: AbstractControl): { [key: string]: any } => {
if (emailForm.value !== control.value ) {
return {
errMsg: '请输入相同邮箱地址'
};
}
return {};
};
}
email = new FormControl('', email())
email2 = new FormControl('', email(email))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有