Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's actually a good argument for the point I was trying to make. Existing validity attributes such as "pattern" are cool, but not enough.

E.g. the "repeat password" example is actually achievable without "setCustomValidity" by using the "pattern" attribute. For that, you would have to dynamically construct a RegEx out of the value from the first input. I didn't want to make the article too long by comparing the solutions, but the point is, with the "customValidity" you see how much more eloquent and easier to read the validation is. So a nicer API here makes all the difference

The "15 word minimum" constraint would look so much nicer as "value.split(/\s+/).length >= 15".




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: