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

RadTimePicker Validation Check

2 Answers 172 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Coty
Top achievements
Rank 1
Coty asked on 12 Jun 2014, 04:10 PM
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:
$("input[id$=rtpStartTime_dateInput").val()
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.

Coty

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Jun 2014, 06:44 AM
Hi Coty,

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

JavaScript:
var picker = $find("<%= rtpStartTime.ClientID %>");
alert(picker.get_textBox().value);

Thanks,
Shinu.
0
Coty
Top achievements
Rank 1
answered on 13 Jun 2014, 02:07 PM
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
}
Tags
General Discussions
Asked by
Coty
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Coty
Top achievements
Rank 1
Share this question
or