I am trying to validate my form in angular using reactive form .There is few fields example card name
in which user enter only string
so he try to enter anything other than string I need to show invalid message .I tried like this
https://codesandbox.io/s/jzq6nn6zz9
constructor(private fb: FormBuilder) {
this.paymentForm = this.fb.group({
cardname: [
"",
[(Validators.required, Validators.pattern("[a-zA-Z][a-zA-Z ]+"))]
],
cardnumber: [""],
dateofexipiredate: [""],
dateofexipireyear: [""],
cvc: [""]
});
}
when I run my application
my form is already valid why ?
it should only valid when user
enter string