atif iqbal
Top achievements
Rank 1
atif iqbal
asked on 05 Mar 2010, 02:46 PM
I have rad datetimepicker control. i want that if user enter date and also time part which is greater than today's date and time then validation message appear.
4 Answers, 1 is accepted
0
robertw102
Top achievements
Rank 1
answered on 05 Mar 2010, 03:54 PM
Just compare the date with the current one like so:
RadDateTimePicker1.SelectedDate.Value > DateTime.Now
The DateTime.Now gets the current date and time on the server.
I hope that helps.
0
atif iqbal
Top achievements
Rank 1
answered on 08 Mar 2010, 11:58 AM
yes, you are correct but i want that when user select date or time and if its greater than today's date and time then immediatley validation occur. i do not want to validate it when another event fire or on postback. thanks
0
Accepted
robertw102
Top achievements
Rank 1
answered on 08 Mar 2010, 04:37 PM
If you want to validate it on the client-side then create a javascript function and assign it to the ClientValidationFunction property of a CustomValidator control.
The validation function would look something like this:
function ValidateDateTime(sender,args) |
{ |
var todaysDate = new Date(); // gets current date/time |
var dateTimePicker = $find("<%=RadDateTimePicker1.ClientID%>"); // gets selected date/time |
if (dateTimePicker.get_selectedDate() > todaysDate) |
{ |
args.IsValid = false; |
} |
else |
{ |
args.IsValid = true; |
} |
} |
I hope that helps.
0
atif iqbal
Top achievements
Rank 1
answered on 09 Mar 2010, 10:48 AM
yea, it works for me, thanks