user123
user123

Reputation: 850

Validation message is not working properly for datetimepicker?

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

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.

Here is the fiddle: 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.

Upvotes: 3

Views: 375

Answers (1)

Darren
Darren

Reputation: 70718

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

Upvotes: 6

Related Questions