How to make a Form Validation when changing focus


I learned about form validation using pattern. But how can I make a validation when the user just changes, for instance, to another text box (focus navigation)? I think it has a better UX


For example, if you have a text input asking for a person’s name, do you want to validate that input’s value after the person tabs out of that input to another input?

If that is the case, then you could use JavaSCript to call a function onblur() or onfocusout() meaning once you tab out of that input field. That function would then validate the input values and add CSS to indicate if the value is good or not.

Great! I didn’t learn JS, just starting HTML again, but good to know. If iclick submit, is there a way to test all field at the same time? For instance, if i click submit on a form that has 5 fields and I have 3 fields filed incorrectly the browser will only show the first error, I want it to show all the 3 errors at the same time. Is it possible?

Thanks a lot