Can you require two form fields to match with HTML5?

后端 未结 7 1651
你的背包
你的背包 2020-11-29 23:56

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 fiel

7条回答
  •  余生分开走
    2020-11-30 00:35

    JavaScript will be required, but the amount of code can be kept to a minimum by using an intermediary element and an oninput form handler to perform the comparison (patterns and validation could augment this solution, but aren't shown here for sake of simplicity):

提交回复
热议问题