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

Validate RadDatePicker with SelectedDate

4 Answers 90 Views
Input
This is a migrated thread and some comments may be shown as answers.
Sucheta Patil
Top achievements
Rank 1
Sucheta Patil asked on 24 Sep 2010, 03:13 PM
Hi
I have a form with field RadDatePicker and its SelectedDate property set to 01/01/1980
How can I validate this control.

<asp:Label ID="lbDOB" runat="server" Text="Date of Birth: (dd/mm/yyyy)"  
             AssociatedControlID="txtDOB" Height="35px" Width="300px"></asp:Label>         
         <telerik:RadDatePicker ID="txtDOB" runat="server" DateFormat="dd/MM/yyyy" 
             Culture="English (United Kingdom)" Width="125px" MinDate="01/01/1950 00:00:00"
              SelectedDate="01/01/1980">               
         </telerik:RadDatePicker>
          <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"
ControlToValidate="txtDOB" ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>

Why cant we use InitialValue='01/01/1980' in RFV.

Thanks in advance.
S

4 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 24 Sep 2010, 08:46 PM
Hello Sucheta,

I'm assuming it includes the timestamp in the SelectedValue, you most likely have to add that part in. So it might look like this: SelectedDate="01/01/1980 00:00:00".

Also, is there a reason why you prevent them from selecting such a date, since you MinDate is set below that date. If you want to ensure they enter a date, you don't need to set a default date in the control for it to validate, since it will validate if the date is null.

I hope that helps.
0
Sucheta Patil
Top achievements
Rank 1
answered on 01 Oct 2010, 12:47 PM
Sorry,
your suggestion doesnt work.
Having a selected date on DatePicker enables a quick way to enter date for user,thats why I want to show it.
I have kept min date 01/01/1950 intentionally, coz there are no students under that year 1950.

Any better ideas are most welcome.
I need to validate the RadDatePicker with the selectedDate  field.
I used the initial value in RFV but it does not work.

Query is not solved!!!

Thanks
Sucheta
0
Cori
Top achievements
Rank 2
answered on 01 Oct 2010, 02:28 PM
In my previous post  I mis-spoke when I told you how to validate the SelectedDate property.

What I meant to say was set the InitialValue property of the RequiredFieldValidator to "01/01/1980 00:00:00". Did you try that?
0
Sucheta Patil
Top achievements
Rank 1
answered on 01 Oct 2010, 02:43 PM
Hi
I tried that.But it doesnt work.

Any better trick!!!
S
Tags
Input
Asked by
Sucheta Patil
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Sucheta Patil
Top achievements
Rank 1
Share this question
or