【问题标题】:jQuery datetimepicker does not support html5 validationjQuery datetimepicker 不支持 html5 验证
【发布时间】:2017-05-16 12:38:15
【问题描述】:

我的表单中有一个日期时间字段:

<input type="text" class="form-control datepicker" required />

$('.datepicker').datetimepicker({
   datepicker: true,
   timepicker: true,
   lang: 'pl'
});

我表单中的每个字段都具有必需的属性。当我尝试使用未填写的必填字段提交表单时,每个字段都返回 html5 验证消息,但 datetimepicker 除外。

谁能告诉我,为什么 jQuery datetimepicker 不支持基本的 html5 验证?有什么办法可以避免这个错误吗?

【问题讨论】:

    标签: jquery html html5-validation jquerydatetimepicker


    【解决方案1】:

    检查一下...

    我已经测试过了。验证正在运行..

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Test HTML5 with Date Picker</title>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#datepicker" ).datepicker();
      } );
      </script>
    </head>
    <body>
    
     <form action="#" method="post">
     <p>Name: <input type="text" id="name" required></p>
    <p>Date: <input type="text" id="datepicker" required></p>
    <input type="submit" value="Submit" />
     </form>
    
    </body>
    </html>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多