Refactor: make general solution for html5 pattern-based errors