验证消息对datetimepicker无法正常工作? [英] Validation message is not working properly for datetimepicker?

查看:72
本文介绍了验证消息对datetimepicker无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的问题是验证datetimepicker并在页面加载后重置值。

Here issue is to validate the datetimepicker and reset the values after page load.

在页面加载验证工作正常但datetimepickers值未重置。

In pageload validation is working properly but datetimepickers values are not reset.

在页面加载后,两个问题值都没有重置且验证不起作用。

After pageload having the both the issues values are not reset and validation is not working.

这是小提琴: 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({}); 

以上是我的代码。

推荐答案

在过滤函数中, mindate maxdate 的值将返回。这是因为 .data()尚未存储来自datepicker的更新值。

In the filter function the value for mindate and maxdate is coming back as null. This is because .data() has not stored the updated value from the datepicker.

我已更新您的代码使用小提琴中显示的日期选择器的值。

I have updated your code to use the value of the datepickers as shown in the fiddle.

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;
    }
});

这篇关于验证消息对datetimepicker无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆