Hacker News new | ask | show | jobs
by ourcat 1708 days ago
Doesn't the HTML input `pattern` attribute help solve this with a RegEx?
1 comments

I'd need to double check, but I was under the impression that it affects a validation check, but that it didn't actually prevent the input of these characters.
You can catch the 'invalidity' of the input with the `oninvalid` JS event, then use that to `e.preventDefault()` and show a message as to why it it failed.
Interesting... I'll investigate this. Thanks!