Do any browsers yet support HTML5's checkValidity() method?

后端 未结 6 1462
轮回少年
轮回少年 2020-12-08 09:00

The HTML5 spec defines some very interesting validation components, including pattern (for validating against a Regexp) and required (for marking a field as required

6条回答
  •  孤街浪徒
    2020-12-08 09:07

    Sure. Opera and Chromium. But you can test yourself:

    function supportsValidity(){
      var i = document.createElement('input');
      return typeof i.validity === 'object'
    }
    

    Here's a link to a sandbox where you can see Opera and Chrome in action: http://jsfiddle.net/vaZDn/light/

提交回复
热议问题