Can you require two form fields to match HTML5?


Is there a way to require the entries in two form fields to match using HTML5? Or does this still have to be done with javascript? For example, if you have two password fields and want to make sure that a user has entered the same data in each field, are there some attributes, or other coding that can be done, to achieve this?

I'm pretty sure it does not exist. And it shouldn't be achieved with JS. Why not validate them with php/asp or any other server side language? Seems to be more secured :)


A few years later, pure HTML5 validation is still not satisfying. As pointed out by @Peteris, a better approach is to use JavaScript for a better UX, and server side validations to make sure user data are formed as expected.

Most frameworks aim this way; eg: AngularJS and Ruby on Rails