RadTimePicker Validation Check

3 posts, 1 answers
  1. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 12 Jun 2014 Link to this post

    I have 2 RadTimePickers on my page, example:
    <telerik:RadTimePicker ID="rtpStartTime" TimeView-HeaderText="Start Time" runat="server" Width="90px" TimeView-Interval="0:15:0" TimeView-StartTime="7:0:0" TimeView-EndTime="17:0:0"></telerik:RadTimePicker>

    I want to validate the value as a valid time, client-side, which looks very possible because it validates already visually by turning red with a caution icon.
    I get the input value like this:
    but that returns the value whether valid or not.

    In the mark-up I can see there is a clientstate hidden input, and there is a "validationText" sub-value that is an empty string when not valid or a date when valid.  I could use this I think but not sure how to grab it.  Here is what that markup looks like:
    <input id="ctl00_ContentPlaceHolder1_rtpStartTime_dateInput_ClientState" name="ctl00_ContentPlaceHolder1_rtpStartTime_dateInput_ClientState" type="hidden" autocomplete="off" value="{"enabled":true,"emptyMessage":"","validationText":"2014-06-12-05-00-00","valueAsString":"2014-06-12-05-00-00","minDateStr":"1980-01-01-00-00-00","maxDateStr":"2099-12-31-00-00-00","lastSetTextBoxValue":"5:00 AM"}">

    Any help is appreciated, thanks.

  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Jun 2014 in reply to Coty Link to this post

    Hi Coty,

    Please try the below JavaScript to access the invalid value in RadTimePicker.

    var picker = $find("<%= rtpStartTime.ClientID %>");

  3. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 13 Jun 2014 in reply to Shinu Link to this post

    Hey there Shinu, thanks for the response it looks like that functionality just returns the value whether valid or not.  I think I found the solution though in the documentation.  The isEmpty() appears to be what I want to use, because if the value is invalid it returns true, if the value is valid it returns false.   Here is the code to check if the time picker has a valid value:
    var picker = $find("<%= rtpStartTime.ClientID %>");
    if (picker.isEmpty()) {
        //value is Bad
    } else {
        //value is Good
Back to Top