简体   繁体   English

无法在 jquery ui datepicker 中更改 dateFormat

[英]Unable to change dateFormat in jquery ui datepicker

I want to change the dateFormat of datepicker in dd-mm-yy.我想在 dd-mm-yy 中更改 datepicker 的 dateFormat。 If I change the date format it is showing please enter a valid date.如果我更改了它显示的日期格式,请输入一个有效的日期。 I have seen other solution but nothing is working.我见过其他解决方案,但没有任何效果。

thank you.谢谢你。

my form我的表格

   <link href="{{ url('css/jquery-ui.min.css') }}" rel="stylesheet">

    <div class="row text-center">

      <div class="col-lg-4 col-md-6 col-sm-12">
      <div class="form-group">
      <div class="row text-center">
      <div class="col-lg-4 col-md-6 col-sm-6">
      Start Date

      </div>
      <div class="col-lg-8 col-md-6 col-sm-6">
      <input  placeholder="Start Date" class="form-control date" name="startdte" readonly>

      </div>
      </div>

        </div>

      </div>
      <div class="col-lg-4 col-md-6 col-sm-12">
      <div class="form-group">
      <div class="row text-center">
      <div class="col-lg-4 col-md-6 col-sm-6">
         End Date
      </div>
      <div class="col-lg-8 col-md-6 col-sm-6">
      <input  placeholder="End Date" class="form-control date" name="enddte" readonly>
      </div>
      </div>

        </div>


 </div>
</div>

<script src="{{url('js/jquery-ui.min.js')}}"></script>  

     $('.date').datepicker({

           //dateFormat:"yy-mm-dd",   this one working
            dateFormat: "dd-mm-yy"  this is not working 

     });


  [1]: https://i.stack.imgur.com/d7qqg.png

Finally the problem is solved.终于问题解决了。 I was getting this error from jquery validation plugin not in datePicker .我从jquery validation plugin收到此错误,而不是在datePicker In jquery validation plugin is not accepting the format dd-mm-yyyy.在 jquery 验证插件不接受格式 dd-mm-yyyy。 to change this U have to do modification in jquery.validation.min.js要改变这个你必须在jquery.validation.min.js做修改

for more informaton Where trigger the "Please enter a valid date."有关更多信息,请在何处触发“请输入有效日期”。 in jquery.validate.js 在 jquery.validate.js 中

也许您已经在上一部分代码中初始化了日期选择器,因此您可能需要使用它来设置值:

$('.date').datepicker("option", "dateFormat", "dd-mm-yy");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM