Form submission if optional field is invalid

If a form has some optional fields what is best way to handle validation for it?

Simplest solution is to not validate the optional fields and simply allow form submission but sometimes we need to validate the optional fields too. So we, validate optional fields when they get focus and its all good.

But how should we proceed if user interact with field so it get validated and shows error, should we allow form submission even if there is a error message or we should disable submit button so user need to fill the correct info or clear the field?

In short,

  • Optional field > not changed > no validation > allow submit.
  • Optional field > changed > trigger validation > valid > allow submit.
  • Optional field > changed > trigger validation > invalid > ???