min/max attribute with type = date on HTML5

后端 未结 2 943
夕颜
夕颜 2021-01-14 06:40

I\'m having some problems to set a minimum and a maximum YEAR with HTML5 date input.

Here is my code:



        
相关标签:
2条回答
  • 2021-01-14 07:12

    Some browsers like Safari and Internet Explorer does not support this functionality, this may be your problem. Write validation via Javascript.

    The list of browers that support this feature can be seen at:...

    http://html5test.com/compare/browser/chrome-33/firefox-27/opera-19/safari-7.0/ie-11.html

    0 讨论(0)
  • 2021-01-14 07:23

    min and max attributes for date input type have very little browser support. You can use jQuery validation as a workaround.

    <input id="dateInput" required="required"  min="1900-01-01" max="2099-09-13" type="date" class="form-control" id="inputDataNascimento">
    <script>
        $("#dateInput").validate();
    </script>
    
    0 讨论(0)
提交回复
热议问题