How to validante FormControl only on blur


#1

I’m using from builder in my forms and I’m creating custom function validators.

But the problem is that the validators are called on the change event which gets a little weird. How could I force validation just on blur?


#2

Can’t you just put an if statement inside your validator, so it only tries to validate if the conditions you desire are satisfied?


#3

Nope. If I’m validating a email using regex it will show error just on first character.


#4

Then write a validator that checks the regex inside an if statement. Though I wonder if your regex is correct. That’s a notoriously difficult problem. I decided not to use a regex at all for that step, because of possible false negatives. I require verified email for some things, and nothing special for other things. I took syntactic validation out of the process almost completely.