How to implement Inline and custom validation in the checkout page?

I’m trying to achieve the inline and custom validation here (or see image below) on the checkout page. I tried this solution (…/inline-errors-in-checkout-fields/
) but it seems it only works if the fields are required. Thanks in advance!
enter image description here