This is a migrated thread and some comments may be shown as answers.

Date Picker Validation Not Working - 2014 release

2 Answers 136 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Jonathan Ruckert
Top achievements
Rank 1
Jonathan Ruckert asked on 25 Mar 2014, 10:04 AM
Hi,

I am trying to get the Validator working on a KendoUI date picker and cannot see what I am doing wrong.

I am attempting to use the following code.
‚Äč
<div id="tickets">
  <label for="datepicker">Start Date</label>
  <input type="date" id="datepicker" name="searchstart" />
  <span class="k-invalid-msg" data-for="searchstart" validationMessage="Test"></span>
</div>
<script>
   $(document).ready(function() {
      $("#datepicker").kendoDatePicker({
          format: "dd/MM/yyyy"
      });
      var validator = $("#tickets").kendoValidator().data("kendoValidator");
    });
</script>

When the page loads, I can type what ever text I want in the date such as "kendo", lose focus on the element and no validation occurs.

I have tested this on both JSBin and Kendo Dojo without any success

What am I missing?

Kind Regards,
Jonathan

2 Answers, 1 is accepted

Sort by
0
Jonathan Ruckert
Top achievements
Rank 1
answered on 25 Mar 2014, 11:07 AM
So I have got something a bit working, however the events are not firing correctly.

I have put together a JSBin explaining the issue that I'm now facing.

If you remove the 4 from the first date picker, then tab to the next field, no validation occurs. If you then re-tab back into the field the validation fires successfully.

Can anyone please shed some light on this please?
0
Alexander Popov
Telerik team
answered on 27 Mar 2014, 09:10 AM
Hello Jonathan,

I already answered to this query in the support thread you opened, but I will copy my response here as well:

This happens because at the time the validation rule is executed, the DatePicker's value is not yet changed. Initially, the value was a valid date, so this is why validation works the second time it is activated. You can manually parse the user input and see if it is a valid date, as seen in this updated example.


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Jonathan Ruckert
Top achievements
Rank 1
Answers by
Jonathan Ruckert
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or