By luke on 2021-06-10
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
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.
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
This is an "interesting" html fact
new reply
new comment