1
votes

Thank you for viewing my post. I have a telerik raddatetimepicker integrated within my project. I have a validation control to ensure the end user selects a date. However, how can I validate that the user selects a time? The default time is set to 12:00AM. So, is there a way that I can produce a code that checks to see if there is "12:00 AM" within the textbox? For example, if the textbox does have "12:00 AM" after the date, it throws up an error, and the user can't proceed. The textbox contains both the date and the time together.

I've researched this a lot, and I can't seem to find a way to validate time in the picker.

Thanks again, and I look forward to hearing what you have to say.

NOTE: MY coding is done with VB, and I'm working in Visual Studio 2010.

Josh

telerik:raddatetimepicker ID="TimeOfCourse" runat="server" 
                        ShowPopupOnFocus="True" Culture="en-US" AutoPostBack="True" 
                        AutoPostBackControl="TimeView" Height="26px" 
                        HiddenInputTitleAttibute="Visually hidden input created for functionality purposes." 
                        Width="200px" 
                        WrapperTableSummary="Table holding date picker control for selection of dates.">
                        <timeview runat="server" cellspacing="-1" columns="8" interval="00:15:00" />
                        <timepopupbutton hoverimageurl="" imageurl="" />
                        <calendar runat="server" usecolumnheadersasselectors="False" userowheadersasselectors="False" viewselectortext="x" />
                        <dateinput runat="server" dateformat="M/d/yyyy" displaydateformat="M/d/yyyy" 
                            labelwidth="" BorderColor="Red" BorderStyle="Solid" BorderWidth="1px" 
                            AutoPostBack="True" Height="26px" />
                        <datepopupbutton hoverimageurl="" imageurl="" />
                    </telerik:raddatetimepicker>
1
Can you please post your code, otherwise we can't help you very much...Sam
Sam, thanks for the reply. I added the source code. The only validator I have is a required field validator for the text box.Josh_with_questions

1 Answers

1
votes

This should do the job (updated)...

 Dim userSelectedTime As String = 'The name of your textbox, example: TextBox1.Text
 userSelectedTime = userSelectedTime.Remove(userSelectedTime.LastIndexOf(":"), userSelectedTime.Length - userSelectedTime.LastIndexOf(":"))
 If userSelectedTime = "00:00" Then
    MsgBox("Please enter a different time.", MsgBoxStyle.Information, "Your app's name")
 End If

The only downside to using this code is that it won't accept the time of 00:00, even if the user genuinely enters 00:00.