简体   繁体   English

验证消息对datetimepicker无法正常工作?

[英]Validation message is not working properly for datetimepicker?

Here issue is to validate the datetimepicker and reset the values after page load. 这里的问题是验证datetimepicker并在页面加载后重置值。

In pageload validation is working properly but datetimepickers values are not reset. 在页面加载验证中工作正常,但不重置datetimepickers值。

After pageload having the both the issues values are not reset and validation is not working. 页面加载后,两个问题值都没有重置,验证不起作用。

Here is the fiddle: http://jsfiddle.net/XHW3w/6/ 这是小提琴: http//jsfiddle.net/XHW3w/6/

enter code here:$("#filter-msg").kendoWindow({
  modal: true,
  visible: false
    });
 $("#reset").click(function () {
 $("#datetimepicker1").val('');
 $("#datetimepicker2").val('');
 });

$("#datetimepicker1").kendoDatePicker({});
 $("#datetimepicker2").kendoDatePicker({}); 

Above is my code. 以上是我的代码。

In the filter function the value for mindate and maxdate is coming back as null . 在filter函数中, mindatemaxdate的值将返回null This is because .data() has not stored the updated value from the datepicker. 这是因为.data()没有存储来自datepicker的更新值。

I have updated your code to use the value of the datepickers as shown in the fiddle. 我已经更新了你的代码,使用了小提琴中显示的日期选择器的值。

http://jsfiddle.net/XHW3w/9/ http://jsfiddle.net/XHW3w/9/

$("#filter").on("click", function () {
   var mindate = $('#datetimepicker1').val();  // uses the val method
   var maxdate = $('#datetimepicker2').val();  // uses the val method

   var product = $("#products").data("kendoDropDownList").value();
   var order = $("#orders").data("kendoDropDownList").value();

    if (!mindate || !maxdate || !product || !order) {
      var content = "";
       if (!mindate) 
        content += "<div class=\"k-error-colored\">mindate is not defined!</div>";
       if (!maxdate) 
        content += "<div class=\"k-error-colored\">maxdate is not defined!</div>";
       if (!product) 
        content += "<div class=\"k-error-colored\">product is not defined!</div>";
       if (!order) 
        content += "<div class=\"k-error-colored\">order is not defined!</div>";

    $("#filter-msg").data("kendoWindow")
        .content(content)
        .center()
        .open();
    return false;
    }
});

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

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