🐾 rigby

Interesting HTML fact

You can use regular expressions to validate form elements without using javascript. All that’s required is a pattern attribute with your regular expression on an HTMLFormElement like an input of type text. Although, if you don’t set the input to required it won’t bother validating before submitting the request. And remember kids, never trust a client!

Comments

Matthias on 2021-06-11

I used that for a while in OJSE, but recently ditched it because it was annoying to have 2 levels of verification. I already had to implement a styled error container for server-side errors. So it was easier to just do all verification on the server side and put all the errors in the same place.

luke on 2021-06-11

Yeah, that's fair. I'm using it for a kind of bizarre reason, I have a comma separated list of \"tags\" and I didn't want to manually explain it's comma separated, so I literally just guide the user by not allowing them to submit e.g. a space divided tag list. It's kind of stupid though because the browser doesn't ever display the regex to the user.

new reply

luke on 2021-06-14

This is an "interesting" html fact

new reply

new comment