This is a migrated thread and some comments may be shown as answers.
RadDateTimePicker and invalid content
3 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 13 Apr 2011, 10:19 AM
Hi,

When I enter some invalid data into a RadDateTimePicker, the field is marked as invalid (warning triangle and red border)- That's nice and fine.
But when I submit the form, however, the page is considered as valid (this.IsValid returns true) and the postback is executed.

How can I prevent the form to do a postback on invalid data?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 14 Apr 2011, 08:07 AM
Hello Macro,

One suggestion to achieve this is by adding RequiredFieldValidator on the page. Using this you can show a warning message and stop the submission of the form if a required field has no value. Set the ControltoValidate property of RequiredFieldValidator to ID of RadDatePicker,.

Please go through the following link to online demo.
Validation

Thanks,
Shinu.
0
Marco
Top achievements
Rank 1
answered on 14 Apr 2011, 08:28 AM
Hello Shinu,

Thanks for your reply. Unfortunately, I cannot mark this field as required, because it is not a required value. Nevertheless, entering invalid data (user uses an invalid date format) has to mark the form as invalid and therefore supress the postback.

Regards.
0
Maria Ilieva
Telerik team
answered on 19 Apr 2011, 01:32 PM
Hello Marco,

I would suggest you to review the following forum post in which a similar scenario is discussed and a possible approach with custom validators is provide.
I hope this helps

All the best,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Asked by
Marco
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or